Friday, April 10, 2009

WCF turn on IncludeExceptionDetailInFaults

Error: 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.System.Exception {System.ServiceModel.FaultException}

Reason/Solution:
When any kind of error occur calling a WCF endpoint from client, client will receive a generic message ( as given above ) for security reason.

If you want to see the full details of the error, you need to change the app.config file for the WCF Host to include full exception details while sending it to clients.

Host App.Config:

<configuration>
<system.serviceModel>
<services>
<!-- Step 1. Add a behaviorConfiguration attribute -->
<service
name="Microsoft.WCF.Documentation.SampleService"
behaviorConfiguration="metadataAndDebug">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/SampleService" />
</baseAddresses>
</host>
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"
/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<!-- Step 2. Add a new behavior below.-->
<behavior name="metadataAndDebug">
<serviceMetadata httpGetEnabled="true" httpGetUrl=""/>
<!-- Step 3. Add a <serviceDebug> element -->
<serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Article:MSDN


This setting is only recommended for DEV purpose.

3 comments:

Zhann September 14, 2010 at 4:47 PM  

Hello. I am really hoping you can help me because I am completely lost. So you know, I know very little about .NET, I am a Java developer by trade, but I was asked to help out here and am trying to find any information possible. The task at hand is simple, we need to get a SharePoint application to authorize either via LDAP or SqlServer authentication. LDAP works fine, however when trying to validate via SQL we get an exception that isn't very detailed stating that for more detail we need to turn on IncludeExceptionDetailInFaults.

I have tried following your tutorial as best I could, it seems to be the most detailed of the tutorials. However, without access to the Source Code behind the login, I am having a very hard time debugging, so my only option is this IncludeExceptionDetailInFaults = true option. However, after following your instructions this error is not changing. I am assuming that is because I don't understand what I need to do properly. Here is the way i see it, please correct me where I am wrong:



The service name is irrelevant. The Behavrior Configuraiton simply needs to map to the name of the behavior specified below.

The Base Address is simply the URL of the site in quesion.

I copied and pasted your behavior block exactly as is, only changing the behavior name to match the configuration name mentioned above.

However, Endpoint is a complete mystery to me. What does this have to be? How do I configure the enpoint? Is there some 'general' endpoint that will always turn on the debug?

Please help, this task is very difficult with what little knowledge I have about .NET.

If you would like, please feel free to email me zhanng at gmail. Thanks in advance.

Zhann September 14, 2010 at 4:50 PM  

Hello. I am really hoping you can help me because I am completely lost. So you know, I know very little about .NET, I am a Java developer by trade, but I was asked to help out here and am trying to find any information possible. The task at hand is simple, we need to get a SharePoint application to authorize either via LDAP or SqlServer authentication. LDAP works fine, however when trying to validate via SQL we get an exception that isn't very detailed stating that for more detail we need to turn on IncludeExceptionDetailInFaults.

I have tried following your tutorial as best I could, it seems to be the most detailed of the tutorials. However, without access to the Source Code behind the login, I am having a very hard time debugging, so my only option is this IncludeExceptionDetailInFaults = true option. However, after following your instructions this error is not changing. I am assuming that is because I don't understand what I need to do properly. Here is the way i see it, please correct me where I am wrong:



The service name is irrelevant. The Behavrior Configuraiton simply needs to map to the name of the behavior specified below.

The Base Address is simply the URL of the site in quesion.

I copied and pasted your behavior block exactly as is, only changing the behavior name to match the configuration name mentioned above.

However, Endpoint is a complete mystery to me. What does this have to be? How do I configure the enpoint? Is there some 'general' endpoint that will always turn on the debug?
Please help, this task is very difficult with what little knowledge I have about .NET.
If you would like, please feel free to email me zhanng at gmail. Thanks in advance.

Sandeep September 14, 2010 at 10:37 PM  

Please make sure you have
IncludeExceptionDetailInFaults=True for HOST config and for client config