XmlSerializer compat switch

XmlSerializer class in .NET 4.5 uses reflection emit to improve the cold startup time of your application. If you happen to run into any compatibility issues on running your existing .NET 40 applications running on a machine with .NET runtime >= 4.5, then you might use the below compat switch in your config file to get the old behavior.

<?xml version="1.0" encoding="utf-8" ?>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />


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



This is equivalent to the compat switch described in this KB article. However the above appSetting based switch is recommended. The compat switch described in this KB article is not compatible on a machine with .NET 4.0 runtime. As application will fail to load due to a configuration exception. The above appSetting based switch is compatible on both runtimes.

Comments (2)

  1. ErikEJ says:

    Should it not be value="true" ?

  2. @ErikJ, good catch. Copy paste error. Thanks for reporting this.

Skip to main content