El Blanco's Office 2007 Blog

Friday, October 13, 2006

"sgen.exe" exited with code 1

Not a MOSS 2007 blog post as such, but an irritating bug I found whilst developing a MOSS application using VS.NET 2005. Building in debug has worked fine for many weeks now, eventually I've got around to building a release build.

Two of the projects in my solution contain web references to a web service and both of these projects were failing with the error: "sgen.exe exited with code 1".

It turns out that even though sgen.exe is passed the /assembly parameter it can ignore this and look at a previous version of the assembly stored in the GAC - hence, if you see this problem, remove the assembly in question from the GAC and it appears to get around the problem and build OK.