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:

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

Now re-build your [...]