Can\'t integrate IErrorHandler into my project with the correct web.config
I have a successfully working WCF that is being consumed by webclients in .net 4 but when tryi
It's a bit late, but for other users here is a better approach (in my opinion) and the code above only has to be changed a little bit
You can change:
public class WcfErrorServiceBehaviour : IServiceBehavior
to:
public class WcfErrorServiceBehaviourAttribute : Attribute, IServiceBehavior
Now you can use this as an attribute for your service-class like this:
[WcfErrorServiceBehaviour]
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall,
ConcurrencyMode = ConcurrencyMode.Multiple)]
public class MXServiceCommands : IMXServiceCommands
{
}
Hope this helps some others.
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- 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="true" />
<errorHandler/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<extensions>
<behaviorExtensions>
<add name="errorHandler" type="CustomerWcfService.WcfErrorHandlerBehaviour, CustomerWcfService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
</behaviorExtensions>
</extensions>
</system.serviceModel>
And then apply your behavior to the service you want it to be applied to.
Edit :
sorry for the miss, but you actually need to remove any line-break and any additional white space in the type name in the extension definition (old WCF bug which force you to use the fully qualified name string in extension type declaration).