Fix for XML Serialization Assembly Generation in Visual Studio 2010

XML serialization assembly generation greatly improves start-up performance of web service proxies. The Framework already supports generation and use of serialization assemblies via the SGEN command or MSBuild task. Visual Studio also purportedly supports this “automatically”. However it doesn’t work because by default it decides whether or not to generate the assemblies based on a proxy type.

However there is a workaround, documented here:

http://stackoverflow.com/a/8798289/1080914

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
     <!-- Snip... -->
     <GenerateSerializationAssemblies>On</GenerateSerializationAssemblies>
     <SGenUseProxyTypes>false</SGenUseProxyTypes>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
     <!-- Snip... -->
     <GenerateSerializationAssemblies>On</GenerateSerializationAssemblies>
     <SGenUseProxyTypes>false</SGenUseProxyTypes>
   </PropertyGroup>

It is necessary to edit the MSBuild XML of the Visual Studio projects where you have XML serializable types to fix the issue with proxy types preventing SGEN execution. The correct answer is hence not the first one in the above forum thread, it is the last one from http://stackoverflow.com/users/94928/heavyd who correctly points out the most graceful way to restore original Visual Studio functionality.

If the “use proxy types” were available in the Visual Studio GUI developers could have fixed this without resorting to hidden project edits. This issue has still not been fixed in Visual Studio 2012.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s