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:
- Open the GAC (C:\Windows\Assembly), find the DLL corresponding to your project.
- Right click on it and select uninstall
Now re-build your project and the problem must be gone.
Filed under: SharePoint Errors and Solutions | Tagged: VS .Net

Thank you, I was experiencing this exact problem and your solution worked perfectly =)
AWESOME! I was looking for a solution to this problem for a few days. Thanks for the info! Worked great.
Sure thing
Thanks allot, I have tried different ways but no able to solve. Your solution worked perfectly
I’ve also encountered cases where I neglected to check the project out of SourceSafe and sgen can’t write to the folders it needs access to. Especially easy to run into when what you’re building is a dependency of the project you really want to run.
Thanks a bunch! It worked for me.
Another thank you…you saved me a LOT of frustration!