Error when Behaviour Extension types are not fully qualified

April 23, 2008 at 12:58 pm | Posted in WCF | Leave a comment

Custom behaviour extensions are a great way to customise service behaviour such as implementing exception shielding as described here in Rory’s post  or message validation using the Microsoft Enterprise Library Validation Application block.

I recently implemented a custom WCF behaviour extension for shielding exceptions when I came across the following cryptic exception.

“An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.”

image

While the message was somewhat cryptic, it pointed me to the service behaviour were I realised I had specified the incorrect version on the type attribute.

Steps

1. Create new behaviour extension. My extension shielded and traced certain exceptions using the IErrorHandler.
2. Use SVC Configuration Editor to plug the extension in. It added the following configuration as expected.

<system.serviceModel>

  <extensions>

    <behaviorExtensions>

      <add name=ErrorHandlerBehavior

           type=Wcf.Demo.Service.ErrorHandlerElement, Wcf.Demo.Service,

                 Version=1.0.0.0, Culture=neutral, PublicKeyToken=null />

    </behaviorExtensions>

  </extensions>

</system.serviceModel>

3. Ran integration unit tests that passed.
4. The service build was integrated into TeamBuild which happen to automatically update my AssemblyInfo version files.
5. As soon as a TeamBuild kicked off and the assembly version changed, I received the cryptic error.
6. I realised I had an incorrect version configured in the web.config so I replaced the fully qualified type with:

<behaviorExtensions>

  <add name=ErrorHandlerBehavior

       type=Wcf.Demo.Service.ErrorHandlerElement, Wcf.Demo.Service />

</behaviorExtensions>

7. Ran tests and failed.

After attempting to diagnose the issue using tools such as Fusion Log Viewer, I checked Google (which I should have done first) and came across several posts also identifying the issue – including a closed and unresolved issue on Microsoft Connect. This is the second time round I have been to Microsoft Connect regarding a bug and it does not look like they will resolve this anytime soon.

A Way Forward

At this stage since there is no fix, a tedious workaround will have to be to get TeamBuild to modify the web.config and update the version number of the behaviour extension when applying a new version – which in my case is for every CI build triggered by a code checkin.

Links

Advertisements

Leave a Comment »

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.
Entries and comments feeds.

%d bloggers like this: