Whats the best way handle exception from a WCF service? How can you throw the exception from a WCF service?
+2
A:
Richard L
2009-01-02 22:50:57
+2
A:
FaultContract is the way to go. MSDN link given in the other response is a good place to look. One thing to note however, is:
Resist the temptation to put Exception-derived classes in your fault contrant
Don't do FaultContract<ArgumentException>
Rather create FaultContract<NameCanNotHaveDigitsFault>
where NameCanNotHaveDigitsFault
is your domain specific class, not tied to particular framework.
Krzysztof Koźmic
2009-01-03 18:00:23
A:
You can throw FaultExceptions from a wcf service, they will be transferred back to the client.
Any other type of exception will put your communication channel into faulted mode, which will render it unusable.
So the easiest (quick & dirty) way to throw exceptions in a wcf service is to wrap/change them into FaultExceptions.
Sam
2009-01-21 11:38:03