I am trying to throw my own native exception from a FaultException from my WCF service and catch it in my WCF client. However, on the client side, the exception is thrown as a non-generic FaultException, and the details of my custom exception are lost.
My own exception:
[Serializable] public class MyCustomException : ApplicationException
{ ... }
Here's how I throw it:
throw new FaultException<MyCustomException>(new MyCustomException("foo bar!"));
(Note that I have [FaultContract (typeof (MyCustomException))] placed on top of my method in the interface)
And this is how I try to catch it in my client:
...
catch (FaultException<MyCustomException> mcex)
{
Console.WriteLine(mcex);
}
catch (FaultException fex)
{
Console.WriteLine(fex);
}
My goal is for the exception to fall into the first catch clause above, but it falls into the second catch clause.
, MyCustomException ApplicationException, FaultException .
, , MyCustomException Serializable ( DataContractSerializer) , , WCF. - ServiceKnownType? ( , ).