FaultContractWrapperException was not handled by user code

Mar 16, 2010 at 5:36 PM

I am new to EntLib and trying to use the Exception shielding feature but no matter what i do i end up getting "FaultContractWrapperException was not handled by user code"
I even created a separate simple WCF project to remove all my code to test  with the same result. When i include the supplied source code for the blocks i can see that this exception is thrown from inside the block by this line of code:
Exception wrappedException = new ExceptionHandlingException(Resources.ExceptionNullException); of IntentionalRetrow method.
I found couple of old references to this, but the solutions described there, like removing try catch block is not working for me.
I am using Windows 7 Ultimate
Can someone please take a look at what i am doing wrong?

Thank you!
This is my server and client code:

Server:
Interface:
namespace WcfService11 {
    // NOTE: If you change the interface name "IService1" here, you must also update the reference to "IService1" in Web.config.
    [ServiceContract]
    public interface IService1 {

        [OperationContract]
        [FaultContract(typeof(TestFault))]
        string GetData(int value);

        [OperationContract]
        CompositeType GetDataUsingDataContract(CompositeType composite);

        // TODO: Add your service operations here
    }
Implementation:
[ExceptionShielding("WCF Exception Shielding")]
    public class Service1 : IService1 {
        public string GetData(int value) {
            try {
                getException();

            }
            catch (Exception ex) {

                bool rethrow = ExceptionPolicy.HandleException(ex, "WCF Exception Shielding");
                if (rethrow) {
                    throw;
                }

            }
            return "Foo";
        }

        private Exception getException() {
            throw new ApplicationException("testing faults");
        }

 TestFault class:
namespace WcfService11 {
    [DataContract]
    public class TestFault {
        public TestFault() {

        }
        private string message;
        private IDictionary data;
        private Guid id;

        [DataMember]
        public string Message {
            get { return message; }
            set { message = value; }
        }

        [DataMember]
        public IDictionary Data {
            get { return data; }
            set { data = value; }
        }

        [DataMember]
        public Guid Id {
            get { return id; }
            set { id = value; }
        }
    }
}
Client:

private static void testMisk()
        {

           
            ServiceReference1.Service1Client sc = new ConsoleApplication2.ServiceReference1.Service1Client();
            try {
                sc.GetData(1);

            }
            catch(FaultException<ServiceReference1.TestFault> ex){
                ServiceReference1.TestFault fault = ex.Detail;
                Console.WriteLine(fault.Message);
                Console.WriteLine(fault.Id);
            }


and this is the entire Web.config:
<?xml version="1.0"?>
<!--
    Note: As an alternative to hand editing this file you can use the
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in
    machine.config.comments usually located in
    \Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration>
  <configSections>
    <section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=4.1.0.0, Culture=neutral, PublicKeyToken=null" />
    <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=null" />
    <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
      <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
        <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
        <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
          <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" />
          <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
          <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
          <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
        </sectionGroup>
      </sectionGroup>
    </sectionGroup>
  </configSections>
  <exceptionHandling>
    <exceptionPolicies>
      <add name="WCF Exception Shielding">
        <exceptionTypes>
          <add type="System.ApplicationException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
            postHandlingAction="ThrowNewException" name="ApplicationException">
            <exceptionHandlers>
              <add exceptionMessage="" faultContractType="WcfService11.TestFault, WcfService11, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
                type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF.FaultContractExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF, Version=4.1.0.0, Culture=neutral, PublicKeyToken=null"
                name="Fault Contract Exception Handler" />
            </exceptionHandlers>
          </add>
        </exceptionTypes>
      </add>
    </exceptionPolicies>
  </exceptionHandling>
  <appSettings />
  <system.web>
    <!--
            Set compilation debug="true" to insert debugging
            symbols into the compiled page. Because this
            affects performance, set this value to true only
            during development.
        -->
    <compilation debug="true">
      <assemblies>
        <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      </assemblies>
    </compilation>
    <!--
            The <authentication> section enables configuration
            of the security authentication mode used by
            ASP.NET to identify an incoming user.
        -->
    <authentication mode="Windows" />
    <!--
            The <customErrors> section enables configuration
            of what to do if/when an unhandled error occurs
            during the execution of a request. Specifically,
            it enables developers to configure html error pages
            to be displayed in place of a error stack trace.

        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
        -->
    <pages>
      <controls>
        <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      </controls>
    </pages>
    <httpHandlers>
      <remove verb="*" path="*.asmx" />
      <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false" />
    </httpHandlers>
    <httpModules>
      <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </httpModules>
  </system.web>
  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
        <providerOption name="CompilerVersion" value="v3.5" />
        <providerOption name="WarnAsError" value="false" />
      </compiler>
    </compilers>
  </system.codedom>
  <!--
        The system.webServer section is required for running ASP.NET AJAX under Internet
        Information Services 7.0.  It is not necessary for previous version of IIS.
    -->
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules>
      <add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </modules>
    <handlers>
      <remove name="WebServiceHandlerFactory-Integrated" />
      <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </handlers>
  </system.webServer>
  <system.serviceModel>
    <services>
      <service name="WcfService11.Service1" behaviorConfiguration="WcfService11.Service1Behavior">
        <!-- Service Endpoints -->
        <endpoint address="" binding="wsHttpBinding" contract="WcfService11.IService1">
          <!--
              Upon deployment, the following identity element should be removed or replaced to reflect the
              identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity
              automatically.
          -->
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="WcfService11.Service1Behavior">
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true" />
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

Mar 17, 2010 at 7:04 AM

Hi,

You config seems to be fine, also the attributes are complete. One thing I want to have you try. Please remove the explicit catching of the exception on your service:

From:

public string GetData(int value)
        {
            try
            {
                getException();

            }
            catch (Exception ex)
            {
                bool rethrow = ExceptionPolicy.HandleException(ex, "WCF Exception Shielding");
                if (rethrow)
                {
                    throw;
                }

            }
            return "Foo";
        }

To:

        public string GetData(int value)
        {
            getException();
            return "Foo";
        }

 

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

Mar 17, 2010 at 3:20 PM

Thanks for the response!

I tried removing try catch before with the same result.

One think that i forgot to mention in my original post is that I only see this error when running the application in debug mode and Visual Studio breaks with green colored break line indicating that the error is coming from a referenced component.

If i close Visual Studio and run my client against IIS deployed service,  all looks good and i don't see any entlib errors posted anywhere, and in my text event log entry i see that the FaultContractWrapperException properly logged as caught. It’s just the knowledge that I have seen the error in dev environment makes me worry before I deploy the solution to production.

Mar 18, 2010 at 7:10 AM

Hi,

"and Visual Studio breaks with green colored break line indicating that the error is coming from a referenced component.", what is that error that is coming from a referenced component? Also, is it intentional that you are referencing the unsigned assemblies of ent lib? Noticed that in your config that the publickeytoken for ent lib assemblies is null.

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

Mar 18, 2010 at 12:53 PM
Hi Valiant, Thanks for helping me out with this, i have a release coming soon and want to make sure that there will be no suprises. The actual error is what i posted as a subject for this discussion "FaultContractWrapperException was not handled by user code" Usually it breaks on the call to ExceptionPlolycy.HandleException line with the unhanded error helper dialog popping up. If i remove ALL try/catches in a chain then it will simply break on the next closing bracket, but the actual application doesn't crash, i can hit f10/11 and continue. I am not actually referencing an unsigned assemblies in the real code, This sample that i posted i created solely for testing to remove all my code from the way and i had the references set to the actual EntLib's source projects from quick starts to try troubleshoot and understand what's happening. Obviously, i recreated one of the policies just like it's in the original service.The same exception is happening in both places and i just posted the test one. As I mentioned before if Visual Studio is not running this error is nowhere to find, in my log location it actually logs as caught: Please see below, this is not thrown from the code i posted, this is from the "real" Service so you can see publickeytokens there, but the error is the same in both cases. As i said if hit continue it will not crash but continue logging as if it was caught. At run time it appears to work smoothly but i have unconfirmed by me yet reports from my users(users of the WCF Service) that they can still see a lot of error information, i will be testing that today and i will post the actual SOAP that ends up returning to user if that's the case... The includeExceptionDetailInFaults is set to false ---------------------------------------- Timestamp: 3/16/2010 7:58:14 PM Message: HandlingInstanceID: f0e6718a-8189-462a-805f-16ee917fd446 An exception of type 'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF.FaultContractWrapperException' occurred and was caught. ----------------------------------------------------------------------------------------------------------------------------------------- 03/16/2010 15:58:14 Type : Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF.FaultContractWrapperException, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 Message : Server was unable to process request. ---> Vermont Error: Unknown error(GetUserProfile_200007) BTN: 1234567890 ---> 200007: BackEnd System Error. Source : Microsoft.Practices.EnterpriseLibrary.ExceptionHandling Help link : FaultContract : PlumChoice.SAFELink.Vermont.Gateway.BusinessObjects.ServiceFault Data : System.Collections.ListDictionaryInternal TargetSite : System.Exception IntentionalRethrow(System.Exception, System.Exception) Stack Trace : at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyEntry.IntentionalRethrow(Exception chainException, Exception originalException) at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyEntry.RethrowRecommended(Exception chainException, Exception originalException) at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyEntry.Handle(Exception exceptionToHandle) at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyImpl.HandleException(Exception exceptionToHandle) at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.HandleException(Exception exceptionToHandle, String policyName, ExceptionPolicyFactory policyFactory) at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.HandleException(Exception exceptionToHandle, String policyName) at PlumChoice.SAFELink.Vermont.Gateway.VermontService.Vasip.getUserProfile(String userId, String phone, String firstName, String lastName, String state, String[] userAccess) in C:\Dev\Vermont\Phase 3\Solution\PlumChoice.SAFELink.Vermont.Gateway\VermontService\Vasip.svc.cs:line 46 at SyncInvokegetUserProfile(Object , Object[] , Object[] ) at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet) Additional Info: MachineName : PCDEV-20 TimeStamp : 3/16/2010 7:58:14 PM FullName : Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 AppDomainName : /LM/W3SVC/1/ROOT/VermontService-1-129132430730387511 ThreadIdentity : WindowsIdentity : IIS APPPOOL\DefaultAppPool Category: Vasip Global Category Priority: 0 EventId: 100 Severity: Error Title:Enterprise Library Exception Handling Machine: PCDEV-20 Application Domain: /LM/W3SVC/1/ROOT/VermontService-1-129132430730387511 Process Id: 3756 Process Name: c:\windows\system32\inetsrv\w3wp.exe Win32 Thread Id: 3300 Thread Name: Extended Properties:
Mar 19, 2010 at 8:41 AM

Hi,

I have a sample that i made based on the code and config that you've posted. Can you please try my sample solution, because it's working on my machine. The FaultException<TestFault> is being catched in the client. I want to send you my sample solution, where can I send it?

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

Mar 19, 2010 at 2:33 PM

Hi  Valiant,

 

I just sent an email to entlib.support@avanade.com with att: Valiant Dudan in the subject.

 

Thank you!


 Arman

Mar 22, 2010 at 7:08 AM

Solution sent .

Mar 24, 2010 at 8:15 AM

Request you to help me also with this.  I'm facing same problem

Mar 24, 2010 at 10:14 AM

Hi,

I have tried the same solution myself using signed assemblies and fortunately has been able make it work with the help of Valiant's idea from the previous post. Just thinking if I can be of any help. :) 

Just let me know the details of your problem.

~ginkapitan

Apr 15, 2010 at 10:09 AM
ginkapitan wrote:

Hi,

I have tried the same solution myself using signed assemblies and fortunately has been able make it work with the help of Valiant's idea from the previous post. Just thinking if I can be of any help. :) 

Just let me know the details of your problem.

~ginkapitan

Can you tell me how should I use signed assemblies?

Apr 15, 2010 at 10:25 AM

Hi,

It is as straight forward as utilizing the assemblies located in the Bin directory of the installed EntLib in your machine (which is the signed assemblies of EntLib). Usually found in [Installation Directory]:\Program Files\Microsoft Enterprise Library 4.1 - October 2008\Bin.

Gino Terrado
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Apr 26, 2010 at 12:24 PM
AvanadeSupport wrote:

Hi,

It is as straight forward as utilizing the assemblies located in the Bin directory of the installed EntLib in your machine (which is the signed assemblies of EntLib). Usually found in [Installation Directory]:\Program Files\Microsoft Enterprise Library 4.1 - October 2008\Bin.

Gino Terrado
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

I used those libraries only. Still i'm getting this exception just observe the below log generated.

Timestamp: 26-Apr-10 11:20:11 AM
Message: Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionHandlingException: The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyImpl, WCF Exception Shielding]) failed: Value cannot be null.
Parameter name: faultContractType (Strategy type ConfiguredObjectStrategy, index 2) ---> Microsoft.Practices.ObjectBuilder2.BuildFailedException: The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyImpl, WCF Exception Shielding]) failed: Value cannot be null.
Parameter name: faultContractType (Strategy type ConfiguredObjectStrategy, index 2) ---> System.ArgumentNullException: Value cannot be null.
Parameter name: faultContractType
   at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF.FaultContractExceptionHandler..ctor(Type faultContractType, String exceptionMessage, NameValueCollection attributes)
   at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF.Configuration.FaultContractHandlerAssembler.Assemble(IBuilderContext context, ExceptionHandlerData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.AssemblerBasedObjectFactory`2.Create(IBuilderContext context, TConfiguration objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
   at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyEntryCustomFactory.Create(IBuilderContext context, ExceptionTypeData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
   at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyCustomFactory.CreateObject(IBuilderContext context, String name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfiguredObjectStrategy.PreBuildUp(IBuilderContext context)
   at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
   --- End of inner exception stack trace ---
   at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
   at Microsoft.Practices.ObjectBuilder2.Builder.BuildUp(IReadWriteLocator locator, ILifetimeContainer lifetime, IPolicyList policies, IStrategyChain strategies, Object buildKey, Object existing)
   at Microsoft.Practices.ObjectBuilder2.Builder.BuildUp[TTypeToBuild](IReadWriteLocator locator, ILifetimeContainer lifetime, IPolicyList policies, IStrategyChain strategies, Object buildKey, Object existing)
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory.BuildUp[T](IReadWriteLocator locator, ILifetimeContainer lifetimeContainer, String id, IConfigurationSource configurationSource)
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.LocatorNameTypeFactoryBase`1.Create(String name)
   at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.GetExceptionPolicy(Exception exception, String policyName, ExceptionPolicyFactory factory)
   --- End of inner exception stack trace ---
   at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.GetExceptionPolicy(Exception exception, String policyName, ExceptionPolicyFactory factory)
   at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.HandleException(Exception exceptionToHandle, String policyName, ExceptionPolicyFactory policyFactory)
   at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.HandleException(Exception exceptionToHandle, String policyName)
   at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF.ExceptionShieldingErrorHandler.ProvideFault(Exception error, MessageVersion version, Message& fault)
Category: General
Priority: -1
EventId: 1
Severity: Information
Title:
Machine: EON2
Application Domain: ec9a0abc-1-129167543990938663
Process Id: 5280
Process Name: C:\Program Files\Common Files\Microsoft Shared\DevServer\9.0\WebDev.WebServer.EXE
Win32 Thread Id: 7920
Thread Name: 
Extended Properties: HandlingInstance ID: - a1ba9ce4-431f-4a40-b705-19c5c7dedfea
 

 

 

My config contains following:
 

  <configSections>
    <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    <section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
      <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
        <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
        <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
          <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" />
          <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
          <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
          <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
        </sectionGroup>
      </sectionGroup>
    </sectionGroup>
  </configSections>
  <loggingConfiguration name="Logging Application Block" tracingEnabled="true"
    defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">
    <listeners>
      <add fileName="trace.log" header="----------------------------------------"
        footer="----------------------------------------" formatter="Text Formatter"
        listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        traceOutputOptions="LogicalOperationStack" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        name="FlatFile TraceListener" />
    </listeners>
    <formatters>
      <add template="Timestamp: {timestamp}&#xD;&#xA;Message: {message}&#xD;&#xA;Category: {category}&#xD;&#xA;Priority: {priority}&#xD;&#xA;EventId: {eventid}&#xD;&#xA;Severity: {severity}&#xD;&#xA;Title:{title}&#xD;&#xA;Machine: {machine}&#xD;&#xA;Application Domain: {appDomain}&#xD;&#xA;Process Id: {processId}&#xD;&#xA;Process Name: {processName}&#xD;&#xA;Win32 Thread Id: {win32ThreadId}&#xD;&#xA;Thread Name: {threadName}&#xD;&#xA;Extended Properties: {dictionary({key} - {value}&#xD;&#xA;)}"
        type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        name="Text Formatter" />
    </formatters>
    <categorySources>
      <add switchValue="All" name="General">
        <listeners>
          <add name="FlatFile TraceListener" />
        </listeners>
      </add>
    </categorySources>
    <specialSources>
      <allEvents switchValue="All" name="All Events" />
      <notProcessed switchValue="All" name="Unprocessed Category" />
      <errors switchValue="All" name="Logging Errors &amp; Warnings">
        <listeners>
          <add name="FlatFile TraceListener" />
        </listeners>
      </errors>
    </specialSources>
  </loggingConfiguration>
  <exceptionHandling>
    <exceptionPolicies>
      <add name="WCF Exception Shielding">
        <exceptionTypes>
          <add type="System.Exception, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
            postHandlingAction="ThrowNewException" name="Exception">
            <exceptionHandlers>
              <add exceptionMessage="" faultContractType="RapidFireAPIServiceFault"
                type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF.FaultContractExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                name="Fault Contract Exception Handler">
                <mappings>
                  <add source="{Guid}" name="Id" />
                  <add source="{Message}" name="MessageText" />
                </mappings>
              </add>
            </exceptionHandlers>
          </add>
        </exceptionTypes>
      </add>
    </exceptionPolicies>
  </exceptionHandling>

 

I'm developing on Windows 7. Will that make any difference?
I'm using Visual Studio 2008 SP1 and opening it by right click and run as administrator. Still i'm having this problem.

Apr 27, 2010 at 1:36 AM

Use the assembly fullyqualifed name of your faultContractType=namespace.RapidFireAPIServiceFault, assemblyName, Version=x, Culture=neutral, PublicKeyToken=null.

 

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

Apr 30, 2010 at 3:18 PM

Thanks a lot Sarah. :)

I just put FullNamespace.RapidFireAPIServiceFault, FullNamespace and it worked. my assembly is not signed.

May 3, 2010 at 6:01 AM

Sarah, 

Its working fine. When exception any exception is thrown, on client side I'm able to catch FaultException<OfMyType>. But on server its not logging the exception.

Please help.

May 3, 2010 at 6:23 AM

I'm able to log exceptions by adding below mentioned handler under exceptionHandlers tag

<add logCategory="General" eventId="100" severity="Error" title="Enterprise Library Exception Handling"
                formatterType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                priority="0" useDefaultLogger="true" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                name="RapidFireAPIFaultLogger" />

But below log is getting generated with the log for exception which is raised.

Timestamp: 03-May-10 5:11:04 AM
Message: HandlingInstanceID: 779dbbbd-0b87-4148-ac26-cd334d79719c
An exception of type 'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF.FaultContractWrapperException' occurred and was caught.
-----------------------------------------------------------------------------------------------------------------------------------------
05/03/2010 10:41:04
Type : Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF.FaultContractWrapperException, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Message : Unknown error occured in the your service application.
Source : Microsoft.Practices.EnterpriseLibrary.ExceptionHandling
Help link : 
FaultContract : FullNamespace.MyAPIServiceFault
Data : System.Collections.ListDictionaryInternal
TargetSite : System.Exception IntentionalRethrow(System.Exception, System.Exception)
Stack Trace :    at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyEntry.IntentionalRethrow(Exception chainException, Exception originalException)
   at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyEntry.RethrowRecommended(Exception chainException, Exception originalException)
   at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyEntry.Handle(Exception exceptionToHandle)
   at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyImpl.HandleException(Exception exceptionToHandle)
   at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.HandleException(Exception exceptionToHandle, String policyName, ExceptionPolicyFactory policyFactory)
   at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.HandleException(Exception exceptionToHandle, String policyName)
   at MyAPIService.GetClientsData(String userName, String passWord) in c:\FullWebServicePath\App_Code\MyAPIService.cs:line 52
   at SyncInvokeGetClientsData(Object , Object[] , Object[] )
   at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)

Additional Info:

MachineName : EON2
TimeStamp : 03-May-10 5:11:04 AM
FullName : Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
AppDomainName : ec9a0abc-1-129173370547610928
ThreadIdentity : 
WindowsIdentity : MyDomain\MyUsername
Category: General
Priority: 0
EventId: 100
Severity: Error
Title:Enterprise Library Exception Handling
Machine: EON2
Application Domain: ec9a0abc-1-129173370547610928
Process Id: 3084
Process Name: C:\Program Files\Common Files\Microsoft Shared\DevServer\9.0\WebDev.WebServer.EXE
Win32 Thread Id: 5060
Thread Name: 
Extended Properties: 

May 3, 2010 at 6:53 AM

Also I hosted the service on IIS on my Windows 7 Dev PC and I couldn't see the trace.log file in the virtual directory. I've explicitly thrown error and debugged into it to see that ExceptionPolicy.HandleException(exception, "WCF Exception Shielding"); code block is executing. Because of this I doubt whether it would get generated on live server or not?

May 5, 2010 at 10:56 AM

Am I right that you got the log you posted from the event viewer?  Check that the account running under IIS has permissions to the directory you're trying to write to.

 

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

May 8, 2010 at 9:10 AM
No, I got that log when I ran it under webdev server within visual studio 2008. Ok I will try giving permissions to the account. 

On Wed, May 5, 2010 at 3:26 PM, AvanadeSupport <notifications@codeplex.com> wrote:

From: AvanadeSupport

Am I right that you got the log you posted from the event viewer?  Check that the account running under IIS has permissions to the directory you're trying to write to.

 

Sarah Urmeneta
Global Technology 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


Oct 2, 2010 at 6:19 PM

Hello,

 

I have the same problem (faultcontractwrapperexception) when I use EntLib 5 with Exception Handling Block Exception Shielding feature. I am using the signed assemblies from the bin directory.

The exception is raised whether I use the feature imperatively (in a catch block) or using the ExceptionShielding attribute.

I use WcfSvcHost and a TestMethod (unittest) to as a service client to run my tests.

Thanks for your help,

-Jonathan

Oct 4, 2010 at 2:28 AM

Things to check:

1.  Does your exception policy has ira PostHandlingAction set to ThrowNewException?

2.  What is the name of your exception policy?  If you're using a name other than "WCF Exception Shielding", it should be specified in the ExceptionShielding attribute.

If these are already applied to your project, you can send me a sample that repros your error so I could take a look.

 

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

Oct 4, 2010 at 3:16 PM

1) Yes it is

2) The name is different than the default and it is specified in the attribute (

[ExceptionShielding("ServiceLayerPolicy"

)]

Oct 5, 2010 at 1:31 AM

Can you post your exceptionHandling section?  As well as your relevant wcf service code?  If you don't want to post it here, a repro project would also be great.

 

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

Oct 5, 2010 at 4:13 PM

here it is:

 

<exceptionHandling>
    <exceptionPolicies>      
      <add name="ServiceLayerPolicy">
        <exceptionTypes>
          <add name="All Exceptions" type="System.Exception, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
            postHandlingAction="ThrowNewException">
            <exceptionHandlers>
              <add name="Logging Exception Handler" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                logCategory="General" eventId="100" severity="Error" title="Enterprise Library Exception Handling"
                formatterType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling"
                priority="0" />
              <add type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF.FaultContractExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                exceptionMessage="An error occured in the service Layer" faultContractType="Company.App.Services.Contracts.Faults.ServiceFault, Company.App.Services.Contracts.Faults, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
                name="Fault Contract Exception Handler" />
            </exceptionHandlers>
          </add>
        </exceptionTypes>
      </add>
    </exceptionPolicies>
Oct 6, 2010 at 1:35 AM

I don't see anything wrong with it.  A small repro project would be helpful.  Or you can debug through the EntLib source code using the PDB files located also in the entlib installation bin folder.

 

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