WCF serialization rules

Service Station, by Aaron Skonnard

Syndication

I recently wrote an article on the various serialization options in WCF (which will soon be published in MSDN Magazine). It focuses on the differences between XmlSerializer, DataContractSerializer (DCS), and NetDataContractSerializer, their programming models, tool support, and when to use one vs. the other.
 
While the WCF team was reviewing my piece, Sowmy (a serialization dev) pointed me to a blog entry he wrote on the DCS rules. It's amazingly succinct as Don pointed out. The piece documents the supported framework types and the precedence rules if a type implements more than one DCS programming model. For example, if a type implements both IXmlSerializable and ISerializable, the former is used.
 
However, the main question the rules raised in my mind was what happens when a type uses [DataContract] and implements IXmlSerializable at the same time. The rules imply that the [DataContract] mapping would be used, while it is seems more logical (to me at least) for IXmlSerializable to kick in. In discussing with Sowmy, it sounds like these "dual projection" scenarios are disallowed in v1 (they throw an exception when found).  
 
Burn these rules into your brain. I'll let you know once my article hits the Web-waves.
 

Posted May 13 2006, 03:00 PM by Aaron Skonnard
Filed under: ,

Comments

Sowmy Srinivasan's WCF Blog wrote Why prevent DataContract + IXmlSerializable
on 05-14-2006 11:14 AM
I left one thing unsaid in the serialization rules and Aaron's sharp eyes caught it promptly. As...
Christopher Steen wrote Link Listing - May 16, 2006
on 05-15-2006 10:24 PM
Custom Partial Output Caching [Via: haacked@gmail.com ]
Dynamically Setting the Page's Title in ASP.NET...
VorpalWolf wrote re: WCF serialization rules
on 10-31-2008 8:48 PM

Hello, I'm currently having the same problem, could you tell me what you refer to when you say it's not allowed in V1? what is V1? sorry for the stupid question

Add a Comment

(required)  
(optional)
(required)  
Remember Me?