Reputation: 3181
I am working on a WCF service and want to use the Enterprise Library ExceptionHandling block to send the fault message back to the client but I am running into a problem. I have found very little on the web about this error.
I added the exceptionHandling block to the web.config and also a reference to exceptionHandling in the configSections but I still get the error.
I have also referenced the ExceptionHandling.WCF dll in my project.
I shouldn't have to do anything else but it still throws the error when I publish and bring the service up in a browser.
Any ideas? This is probably something very simple but I just can't find the problem. Below are the pertinent sections in my web.config:
<section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<exceptionHandling>
<exceptionPolicies>
<add name="WCF Exception Shielding">
<exceptionTypes>
<add type="System.InvalidOperationException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" postHandlingAction="ThrowNewException" name="ArgumentNullException">
<exceptionHandlers>
<add
type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF.FaultContractExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF"
name="DefaultFaultContract Handler"
faultContractType="Bursteg.Samples.WCFIntegration.ServiceContracts.ServiceFault, Bursteg.Samples.WCFIntegration.ServiceContracts">
<mappings>
<add name="Id" source="{Guid}"/>
<add name="MessageText" source="{Message}"/>
</mappings>
</add>
</exceptionHandlers>
</add>
</exceptionTypes>
</add>
</exceptionPolicies>
Upvotes: 0
Views: 4377
Reputation: 3181
I figured it out. The exceptionHandling reference needs to be a direct child of the configSections. I had it a couple of nodes up so it was not referenced. Just thought I would pass on my solution.
Also, as a side not, the only reference I made was to Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF
<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>
Upvotes: 4
Reputation: 4555
do you have a closing tag for <exceptionHandling>
or did you just forget to copy/paste it in your sample?
Upvotes: 0