7/29/2007

WCF Service Debugging with the serviceDebug element.

Learning the "WCF way to do stuff" that you already know how to do is hard enough - but being able to debug boo-boos and fix them along the way can be an important part of your toolset. Since WCF services can return complete exception detail of a fault back over to the client, an easy way to enable this is to add the debug element:

<behaviors>
<serviceBehaviors>
<behavior name="serviceBehavior" >
<serviceDebug includeExceptionDetailInFaults="True" httpHelpPageEnabled="True"/>
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>

the <serviceDebug element with the includeExceptionDetailInFaults and optional httpHelpPageEnabled attributes turns on this cool stuff for debugging.

So if an exception occurs, it gets marshaled back to the client where you can see it.

See here for details.

Finally, Nicholas Allen has a wonderful downloadable GIF diagram of WCF configuration schema.