Serialization or deserialization failures when you run existing XML serialization code in WCF 4.5


When you run existing XML serialization code in Microsoft Windows Communication Foundation (WCF) 4.5, some serialization or deserialization failures may occur.

Note The existing XML serialization code was compiled and run successfully in Microsoft WCF 4.


The XmlSerializer class is optimized to remove its dependency on the C# compiler in WCF 4.5. This optimization improves performance greatly for cold startup scenarios. However, this optimization may cause some differences in the serialization behavior from WCF 4.


To resolve this issue, apply one of the updates that are described in the following Knowledge Base (KB) articles:
2805221 An update is available for the .NET Framework 4.5 in Windows 7 SP1, Windows Server 2008 R2 SP1, Windows Server 2008 SP2, and Windows Vista SP2: May 2013
2805222 An update is available for the .NET Framework 4.5 in Windows 8, Windows RT and Windows Server 2012: May 2013
Note For more information about this issue, see "Issue 1" in the "WCF" section.


To work around these serialization issues, you can set the XmlSerializer class to revert to WCF 4.0 behavior. To do this, use the following configuration element:
<xmlSerializer useLegacySerializerGeneration="true"/>
Note We do not recommend that you apply this workaround on a computer that is running a version of the .Net framework that is earlier than the .Net framework 4.5.

Article ID: 2748720 - Last Review: Jun 6, 2013 - Revision: 1