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
How to Crop a Polygonal Area from an Image in a Winform Picturebox
Is There Any JSON Web Token (Jwt) Example in C#
ASP.NET Webapi: How to Perform a Multipart Post with File Upload Using Webapi Httpclient
Convert Rows from a Data Reader into Typed Results
Comparing Timer with Dispatchertimer
Compile and Run Dynamic Code, Without Generating Exe
ASP.NET MVC Dropdown List from Selectlist
Could We Save Delegates in a File (C#)
How to Get the Taskbar's Position and Size
How to Make a Background Worker Thread Set to Single Thread Apartment
.Net Regex Matching $ with the End of the String and Not of Line, Even with Multiline Enabled
How to Compare Unicode Characters That "Look Alike"
What Method in the String Class Returns Only the First N Characters
Should I Use Appdomain.Currentdomain.Basedirectory or System.Environment.Currentdirectory