I have service configured for FaultException but on the client end I am not getting the exception caught in
catch (FaultException<MyServiceFault> fe)
{
}
instead it is always caught in
catch (FaultException fx)
{
}
I am using selfhost and channelfactory.
my Service:
[FaultContract(typeof(MyServiceFault))]
public string HelloWorld()
{
int a=5;
try
{
var b = a/0;
}
catch(Exception e)
{
throw new FaultException<MyServiceFault>(new MyServiceFault(){Message ="Divide by zero"}, "Divide by Zero");
}
}
I also have the [DataContract]
attribute on the MyServiceFault
.
I am wondering if I miss any configuration.