Trying to compile a C# project with some Web Referenes via the SharpDevelop IDE I take an error message, that the “Compilation task failed because sgen.exe was not found”.
Sgen.exe is a XML Serializer Generator tool which creates an XML serialization assembly for types in a specified assembly in order to improve the startup performance of a XmlSerializer when it serializes or deserializes objects of the specified types. The
Sgen.exe tool generate those assemblies in advance and these assemblies can then be deployed with the application. The XML Serializer Generator can also improve the performance of clients that use XML Web service proxies to communicate with servers because the serialization process will not incur a performance hit when the type is loaded the first time. These generated assemblies cannot be used on the server side of a Web service. This tool is only for Web service clients and manual serialization scenarios.
By default, the project properties set the “Generate serialization assembly” to “Auto”. And this generate the error when going to build a project that the system found the need of Serializer Generator usage, and the tool not found.
One simply and fast solution is to set the “Generate serialization assembly” property to “Off”, but this is not a good idea in general because when the XML Serializer Generator is not used, an XmlSerializer generates serialization code and a serialization assembly for each type every time an application is run.
The sgen tool does not installed with the .net framework, but with the only with the MS SDK for Windows 7 and .NET Framework, so, the fastest and lightweight sollution available, without installing the MS Whindows SDK, is it to download the SDK in iso format, open the iso images with an archive manager wich support iso files (such as the open source 7Zip) and extract the sgen tool following the steps above:
- Firstly extract the
- Open the extracted cab1.cab and extract the files
- Rename the first file to
sgen.exe and to
sgen.exe.config the other.
- Put these files to
- And you finished! Now try to compile your project 😉
*in my example I use the .net framework 3.5, for another version you must download the appropriate SDK and put the files at the
C:WINDOWSMicrosoft.NETFrameworkvX.X you target.