Error "sgen.exe" exited with code 1

While building a project or solution, if you get the error like: “sgen.exe” exited with code 1, then the most probable reason is because you have a different version of the same project’s DLL in the GAC.

Solution:

  1. Open the GAC (C:\Windows\Assembly), find the DLL corresponding to your project.
  2. Right click on it and select uninstall

Now re-build your project and the problem must be gone.

About the author

I work with customers helping them achieve more using Microsoft Technologies. I am in my 9th year with Microsoft as of March 2020. I get to work with really smart people (both at Microsoft and Customers). Helping customers, removing any blockers, rapid prototyping is my core work.