Turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server

Trevor picture Trevor · Nov 29, 2011 · Viewed 312.4k times · Source

I have a WCF service that has been working perfectly, and something has changed and I don't know what.

I get this exception:

System.ServiceModel.FaultException: The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs.

This is confusing because I am running .NET 4.0.

Where do I turn on IncludeExceptionDetailInFaults? I'm battling to find it.

Answer

Otiel picture Otiel · Nov 29, 2011

Define a behavior in your .config file:

<configuration>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="debug">
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    ...
  </system.serviceModel>
</configuration>

Then apply the behavior to your service along these lines:

<configuration>
  <system.serviceModel>
    ...
    <services>
      <service name="MyServiceName" behaviorConfiguration="debug" />
    </services>
  </system.serviceModel>
</configuration>

You can also set it programmatically. See this question.