For the following exception no Reason is specified in the exception window (->view details):
System.ServiceModel.FaultException The creator of this fault did not specify a Reason. How can I change it to show the reason? (I need 1234 to be shown there)
public class MysFaultException
{
public string Reason1
{
get;
set;
}
}
MyFaultException connEx = new MyFaultException();
connEx.Reason1 = "1234";
throw new FaultException<OrdersFaultException>(connEx);
The WCF service chose to not show the reason behind the general error using
includeExceptionDetailInFaults="false"
. You can change it in the configuration file:You don't need to create your own exception. The
FaultException
will wrap the real exception thrown in your service and show you the message and relevant information.