Fault Serialization with XmlSerializer

About 20 posts ago, back before PDC, this was the next topic in the queue to be posted. It has been somewhat delayed by all of the talk of product announcements and details about future releases. Since it was becoming lonely and forgotten I thought I'd get back onto talking about the product that you're actually using. I think I'm going to keep the style of not linking continuity between posts. No one complained when the forward references went away and it seems to make the posting schedule a bit more flexible to accommodate announcements and current events.

I'm using XmlSerializer for my messages but when I send a fault by throwing a FaultException, the fault exception detail gets serialized by DataContractSerializer. Is there some way to avoid data contracts here?

Yes, there is a convoluted way of implementing fault serialization yourself to customize how this is done.

In Orcas SP1/Indigo SP2, we added a new feature to make this simple. The XmlSerializerFormat attribute now has an additional property called SupportFaults. If you set it to true, XmlSerializer is used for reading and writing faults. If you set it to false, DataContractSerializer is used instead. The default is false since that was the behavior before.