This project is read-only.

WCF – Advanced Error Handling and IErrorHandler

Feb 2, 2010 at 12:20 PM


On your site, you are referencing a link to your blog about advanced error handling and IErrorHandler.

I've been trying to use the xml configuration you are giving in your blog with the version or WcfContrib. It doesn't work.

So I've been searching in the version for the type="WcfContrib.Errors.ServiceErrorHandlerBehaviorExtensionElement, WcfContrib, Version=, Culture=neutral, PublicKeyToken=242f357400093587"

I can't find that type ServiceErrorHandlerBehaviorExtensionElement, especially in the WcfContrib.Errors namespace.

Could you tell me how to use this ? or it can't be used by default and you are providing wrong documentation samples ?

Thanks for your time and maybe answer.

Feb 2, 2010 at 1:17 PM

Hi emualliug,

There's a reference to that blog post for demonstrating the purpose and general usage guideline that this behavior was intended for.
The post is old and did not reference any state of WcfContrib that was actually published to CodePlex.
The behavior itself was modified too. (no longer has a property called CreateMessageBuffer for example)

I understand that it isn't clear enough that the post doesn't reflect the version published here, I will handle that.

Regarding the issue at hand:

The behavior extension element never made it to the published versions on CodePlex.
Until it is added, you can apply the behavior in one of the following ways:

  1. Use a declarative approach:
    Use WcfContrib.Errors.ErrorContextHandlerAttribute to decorate your service implementation and provide it with the type to your custom handler in the constructor
  2. Use a programmatic approach:
    You can add the behavior directly to the service host description behaviors. (WcfContrib.Errors.ErrorContextHandlerBehavior)
    You can use the behavior implementation for attaching it quickly:
    ErrorContextHandlerBehavior.AddContextHandler(myServiceHost.Description, new MyErrorHandler());
  3. Use a configuration approach:
    According to your question, that is the way you tried to attach the behavior.
    Since the extension element isn't currently available in the published version, in case that it is your need, you can create your own behavior extension element that creates the behavior from WcfContrib for the time being.

There's a sample in the Show Cases package if you like to check the code. (for both options 1 and 2)

Thanks for notifying me about the incompatibility between the post and the current state, I am sorry for the inconvenience.

Amir Zuker


Feb 2, 2010 at 3:37 PM

Thank you for your quick answer.

For now I'll just be using the WcfContrib.dll assembly that you are providing in your blog about that useful configuration model.

It seems to work quite fine.


Guillaume Bibaut

Feb 5, 2010 at 5:34 PM

Hi Guillaume,

I added the extension element you needed in WcfContrib v2.1.

You can download the new samples, the Service Error Logging service project contains a sample of the configuration.

I hope it suits your needs.

Amir Zuker