July 07, 2010

XMLSerializer and .NET CLR (sgen.exe)

You might have spotted on your .NET projects in Visual Studio a radiobutton to turn on/off serialization "Generate serialization assembly" in your project's property's Build tab , so what's that all about?

Serialization is a mechanism for recreating .NET objects from text. There's another post in this blog on the topic. So why is this option on your project? in brief it's there as a performance improvement for .NET CLR.

.NET serializes the assemblies when loading, if you tick the "Generate serialization assembly" listbox your creating a second assembly to accompany the original, the second assembly , with extension .xmlserialize.dll , will be loaded by the CLR at load load if it exists, this improves performance at load time because now the CLR does not have to serialize the original assembly at load time instead if can just load the already existing second assembly.

The second assembly is generated with Visual Studio with a tool called sgen.exe.

No comments: