Turn on Includeexceptiondetailinfaults (Either from Servicebehaviorattribute or from the <Servicedebug> Configuration Behavior) on the Server

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

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.

Set IncludeExceptionDetailInFaults to true in code for WCF

Yes, sure - on the server side, before you open the service host. This would however require that you self-host the WCF service - won't work in IIS hosting scenarios:

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

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

// if not found - add behavior with setting turned on
if (debug == null)
{
host.Description.Behaviors.Add(
new ServiceDebugBehavior() { IncludeExceptionDetailInFaults = true });
}
else
{
// make sure setting is turned ON
if (!debug.IncludeExceptionDetailInFaults)
{
debug.IncludeExceptionDetailInFaults = true;
}
}

host.Open();

If you need to do the same thing in IIS hosting, you'll have to create your own custom MyServiceHost descendant and a suitable MyServiceHostFactory that would instantiate such a custom service host, and reference this custom service host factory in your *.svc file.

Getting error while invoking WCF service from MVC project

Your WCF service throwing an exception. Change this in your WCF config to get the exception message from service:

      <serviceDebug includeExceptionDetailInFaults="true"/>

You will want to change this back to false when deploying to production environment.

HTH



Related Topics



Leave a reply



Submit