Computers, Programming, Technology, Music, Literature

Archive for the ‘WCF’ Category

Enable WCF help page and exception details in FaultException

leave a comment »



via config file

			<service name="HWService" behaviorConfiguration="metadataAndDebug">
						<add baseAddress="http://localhost:8080/HWService" />
				<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
				<behavior name="metadataAndDebug">
					<serviceMetadata  httpGetEnabled="true" httpGetUrl=""/>
					<serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true" />

via code

ServiceHost host = new ServiceHost(typeof(HWService));

ServiceDebugBehavior debug = host.Description.Behaviors.Find<ServiceDebugBehavior>();

// if not found,  turn the setting on with a behavior
if (debug == null)
         new ServiceDebugBehavior() { IncludeExceptionDetailInFaults = true });
    // make sure setting is on
    if (!debug.IncludeExceptionDetailInFaults)
        debug.IncludeExceptionDetailInFaults = true;



via code (with attribute)


public class HWService : IHWService
	//code 😉

Written by gmaran23

March 20, 2013 at 9:39 am

Posted in .Net, C#, WCF

Tagged with , ,