New WCF Bug fixes released in KB2805222

Damir Dobric Posts

Next talks:

 

    

Follow me on Twitter: #ddobric



 

 

Archives

In the .NET Framework 4.5, WCF introduces a new method named "Reflection Emit" that generates the XML Serialization assembly. This method enables scenarios where the client application cannot write a temporary serialization assembly to disk. In some cases, this may cause issues after you upgrade to the .NET Framework 4.5.
The ability to opt out of this new behavior and revert to the WCF 4 XML serialization is documented in the following KB article:

2748720

(http://support.microsoft.com/kb/2748720/ )

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

In a .NET Framework 4.5-based application, you can use the following code as the workaround that is described in KB 2748720:

<configuration>    <system.xml.serialization>        <xmlSerializer useLegacySerializerGeneration="true"/></system.xml.serialization><configuration>

Assume that you also use the same application.config file or web.config file to target both the .NET Framework 4 and the .NET Framework 4.5. In this situation, you encounter an exception that indicates the <xmlserializer> element cannot be recognized under the <system.xml.serialization> attribute.
For applications that try to target the .NET Framework 4 and the .NET Framework 4.5, we recommend that you apply the following <appSetting> configuration to a replace the previous switch:

<appSettings>    <add key="System:Xml:Serialization:UseLegacySerializerGeneration" value="true"/></appSettings>

Notes

  • Both switches work in the .NET Framework 4.5. However, the <appSettings> switch will make sure that the app.config file or web.config file can be transferred between the .NET Framework 4.0 and the .NET Framework 4.5. If you apply both the switches, only the <appSettings> switch will be used.
  • When a .NET Framework 4.0 application uses the "UseLegacySerializerGeneration" configuration element, the application returns a configuration error.

This update also resolves the following issues after you upgrade to the .NET Framework 4.5.
Issue 1
When you deserialize simple arrays that are serialized as an XmlAttribute, the operation fails. Additionally, you receive the following error message:

System.XML.XmlException ‘EndElement’ is an invalid XmlNode Type.

After you upgrade to .NET Framework 4.5, IIS may return an HTTP400 - 'Bad Request' error.
Issue 2
Consider the following scenario:

  • A base class "A" and a derived class "B" try to serialize or deserialize an object of "B".
  • A virtual property is defined in "A" and is overridden by "B".

In this scenario, the serializer outputs the property that is defined in "A" instead of "B".

 

DOWNLOAD KB: http://support.microsoft.com/kb/2805222


Posted Jun 18 2013, 10:35 AM by Damir Dobric
Filed under:
developers.de is a .Net Community Blog powered by daenet GmbH.