c# – sgen.exe fails during build – Stack Overflow

After adding a new 3rd party reference to a project and then building for Release configuration I got this error (not present when in debug build):
Error Could not load file or assembly ‘x’ or one of its dependencies. The system cannot find the file specified. SGEN  

Here is a solution that worked for me:

If you are having this problem while building your VS.NET project in Release mode here is the solution: Go to the project properties and click on the Build tab and set the value of the “Generate Serialization Assembly” dropdown to “Off”. Sgen.exe is “The XML Serializer Generator 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.” (MSDN)

Source: c# – sgen.exe fails during build – Stack Overflow

Leave a Reply

Your email address will not be published. Required fields are marked *