Published

WCF Fault Detail serialization does not support XmlSerializerFormat?

Just found out WCF does not supporting XmlSerializerFormat for custom fault details (see note under Creating Strongly Typed Faults section here). Everything else in my contracts is defined using this approach and now I have to use DataContracts for my fault details? What’s up with that? Seems superbly lame and inconsistent to me.

Gonna have to take this one to the forums and possibly to the bug database…

Update: No response to my forum post as of yet, so I entered a bug. Go vote on it if you agree that this inconsistency in the API is “teh suck”.

Share this:

Leave a comment

Prompted by your comment (and I totally agree with it, btw), I’ve been playing around to see if there could be some hidden extensibility point down there where you could hook a custom fault serializer. The sad news is: It’s *almost* there. In theory, I think one should have been able to just create a custom FaultException<T>-derived class that overrides CreateMessageFault() to return a custom MessageFault-derived class. The problem? The fault handling code in WCF is a mess, at least in so far as I can gleam using reflector. It’s incredibly inconsistent, and they shortcut themselves in several parts completely skipping the virtual CreateMessageFault() in several scenarios and instead using static variations that don’t allow any extensibility (and sometimes they even skip this completely and use other internal classes to generate the exception). What a mess!