Quantcast
Channel: The Chronicles of Nojo
Viewing all articles
Browse latest Browse all 49

FaultException

$
0
0
If you're stuck trying to get WCF to play nicely with a FaultException<T> where T is a custom System.Exception-derived type, you may be interested to know that the exception needs to have this protected constructor in order to work as expected:
[Serializable]
public class NotFoundException : ApplicationException {
public NotFoundException() {
}

protected NotFoundException(SerializationInfo info, StreamingContext context)
:base(info, context) {
}
}
Without it, WCF will not deserialize your custom exception properly, and you'll (at best) be able to catch a non-generic FaultException (with the rather unhelpful reason of "The creator of this fault did not specify a Reason."

Viewing all articles
Browse latest Browse all 49

Trending Articles