I would like to throw custom exception like some error message as an exception from WCF web service and trying receiver this exception error message in client app on calling web service method.
how to throw custom exception from WCF web Service and receive same exception error at client side.
WCF Web Service Method:
public bool Read()
{
if (IsUserValid() == false)
{
throw new Exception("Authorized user");
}
}
At Client Side
try
{
_client.Read();
}
catch (Exception e)
{
MessageBox.Show(e.Message);
return;
}
Result: Always throw error message as an exception **i.e.
"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 code is throwing exception but not returning same error message as thrown from WCF web service as an exception error
Please suggest