WCF – Advanced Error Handling and IErrorHandler

Feb 2, 2010 at 11:20 AM

http://blogs.microsoft.co.il/blogs/zuker/archive/2009/03/23/wcf-advanced-error-handling-and-ierrorhandler.aspx

Hi,

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 2.0.0.0 or WcfContrib. It doesn't work.

So I've been searching in the version 1.0.0.0 for the type="WcfContrib.Errors.ServiceErrorHandlerBehaviorExtensionElement, WcfContrib, Version=1.0.0.0, 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.

Coordinator
Feb 2, 2010 at 12: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 2: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.

Cheers.

Guillaume Bibaut

Coordinator
Feb 5, 2010 at 4: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.

Regards,
Amir Zuker