EntLib5 ExceptionShielding Issue

Topics: Enterprise Library Core, Exception Handling Application Block, General discussion, Pre-release discussions
Feb 22, 2010 at 3:30 AM

Hi,I wrote an example using WCF ExceptionShielding ,and I always got an error like this:

 

Message:An error has occurred while consuming this service. Please contact your administrator for more information. Error ID: b461d1dd-840b-4e32-9cf9-a7365dc434df

Server stack trace:
   在 System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
   在 System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   在 System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
   在 System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   在 System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]:
   在 Artech.WcfServices.Clients.Program.Main(String[] args) 位置 C:\Downloads\EnterLibIntegration\EnterLibIntegration\Demo\Clients\Program.cs:行号 29
   在 System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
   在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   在 System.Threading.ThreadHelper.ThreadStart()

 

And my environment is VS2010 beta2 ,I try run this example in .net3.5 ,but no matter what I changed in code ,it show the error all the time.

Please someone help!

Feb 22, 2010 at 3:32 AM

My App.config on the host:

<configuration>
  <configSections>
    <section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
  </configSections>
  <exceptionHandling>
    <exceptionPolicies>
      <add name="myExceptionPolicy">
        <exceptionTypes>
          <add name="DivideByZeroException" type="System.DivideByZeroException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
              postHandlingAction="ThrowNewException">
            <exceptionHandlers>
              <add type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF.FaultContractExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF, Version=5.0.208.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                  exceptionMessage="Calculation Error" faultContractType="Artech.WcfServices.Contracts.MyFaultContract, Artech.WcfServices.Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
                  name="Wrap Handler" />
                  <mappings>
                    <add source="{Guid}" name="FaultID" />
                    <add source="Message" name="FaultMessage" />
                  </mappings>
            </exceptionHandlers>
          </add>
        </exceptionTypes>
      </add>
    </exceptionPolicies>
  </exceptionHandling>
  <system.serviceModel>
    <services>
      <service name="Artech.WcfServices.Services.CalculatorService">
        <endpoint address="net.tcp://localhost/calculatorservice" binding="netTcpBinding"
          contract="Artech.WcfServices.Contracts.ICalculator" />
      </service>
    </services>
  </system.serviceModel>
</configuration>

Feb 22, 2010 at 3:35 AM

My Fault Contract:

    [DataContract]
    public class MyFaultContract
    {
        [DataMember]
        public Guid FaultID { get; set; }
        [DataMember]
        public string FaultMessage { get; set; }
    }
}

My Contract :

[ServiceContract(Namespace = "http://www.BeyondOffice.com/")]
    public interface ICalculator
    {
        [OperationContract]
        [FaultContract(typeof(MyFaultContract), Action = "http://www.BeyondOffice.com/fault")]
        int Divide(int x, int y);
    }

Feb 22, 2010 at 3:36 AM

The host Service:

[ExceptionShielding("myExceptionPolicy")]
    public class CalculatorService : ICalculator
    {
        public int Divide(int x, int y)
        {
            return x / y;
        }
    }

Feb 22, 2010 at 10:13 AM

Hi,

I tried using the config that you've provided. I have noticed when I try to open it using the ent lib config tool, your fault contract exception handler is not recognized as the normal faultcontract exception handler instead, it is recognized as if it is a custom exception handler. Did you create the config by hand? or using the ent lib config tool. What you can try is to remove your fault contract exception handler then add a new one. I have created a working sample for this one, if you'll be interested, send us a mail and we'll send you the sample solution.

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Feb 23, 2010 at 3:17 AM

Hi,

I have sent an email to entlib.support@avanade.com ,and I am waiting for the sample solution.

Once I find the truth ,I will post it here.

Feb 23, 2010 at 7:54 AM

I've already sent it....

Feb 24, 2010 at 9:14 AM

Hi,AvanadeSupport

Thanks again!

I have found the bug in  ExceptionShielding attribute .

Before getting the sample code ,I wrote ExceptionShielding attribute in my code like this

[ExceptionShielding(ExceptionPolicyName = "myExceptionPolicy")]

And the bug was always showed ,after I try

[ExceptionShielding("WcfMembershipPolicy")]
all become nice...

Apr 6, 2011 at 12:54 PM

Hi,

I am facing the similar issue with entlib 5.0, Windows 2k8 R2 (64 bit), visual studio 2010.

Checked all possible parameter but no success.

Apr 7, 2011 at 1:18 AM

The repro you sent to me uses the ExceptionShielding attribute which takes no parameter, you're just setting the ExceptionPolicyName property.  You should do the same as what volcanodeng did,

[ExceptionShielding("WcfMembershipPolicy")]

This is necessary since this makes use of the constructor which, aside from setting the ExceptionPolicyName, it also sets the necessary IContractBehavior, IServiceBehavior, and IErrorHandler objects to be used.

 

Sarah Urmeneta
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Apr 7, 2011 at 2:28 PM
Hello Sarah,

Thanks for the response.

I even tried to do as you suggested : [ExceptionShielding("WcfMembershipPolicy")]

But it always gives me the following response:




<faultcode>s:Server</faultcode>
<faultstring xml:lang="en-US">An error has occurred while consuming this service. Please contact your administrator for more information. Error ID: 96bf9c7a-dafb-4a58-a914-718314a3b33d</faultstring>




Were you able to make my code work on your end? If yes, I would highly appreciate if you could send me the updated files. I have exhausted all possible ways to fix it but somehow the exception policy is not getting hooked up.

Appreciate your help.

-Vivek


From: [email removed]
To: [email removed]
Date: Wed, 6 Apr 2011 18:19:01 -0700
Subject: Re: EntLib5 ExceptionShielding Issue [entlib:151278]

From: AvanadeSupport
The repro you sent to me uses the ExceptionShielding attribute which takes no parameter, you're just setting the ExceptionPolicyName property. You should do the same as what volcanodeng did,
[ExceptionShielding("WcfMembershipPolicy")]
This is necessary since this makes use of the constructor which, aside from setting the ExceptionPolicyName, it also sets the necessary IContractBehavior, IServiceBehavior, and IErrorHandler objects to be used.

Sarah Urmeneta
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com
Read the full discussion online.
To add a post to this discussion, reply to this email (entlib@discussions.codeplex.com)
To start a new discussion for this project, email entlib@discussions.codeplex.com
You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.
Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com
Apr 8, 2011 at 12:46 AM

I already sent the working solution.

 

Sarah Urmeneta
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Jun 11, 2013 at 8:02 PM
This bug still exists with EL 6. Is there a work item to fix it? Just to make clear: the behaviour should surely be the same when using the explicit form [ExceptionShielding(ExceptionPolicyName="X")] as when using [ExceptionShielding("X")].
Jun 11, 2013 at 8:38 PM
Edited Jun 11, 2013 at 8:38 PM
Yes, there is a work item*: http://entlib.codeplex.com/workitem/33762

*I just created a work item so as of this post there is a work item. If you meant as of your post, then the answer was no. :)

Thanks for bringing that to our attention.

~~
Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to