TeamCity: sgen.exe exited with code 1 because of C++ DLL

On our experimental TeamCity build machine, a build was failing in Release configuration (but not in Debug configuration) with the message:

"sgen.exe" exited with code 1.

The same project was building just fine on developer machines.

Googling the failure message turned up some pages suggesting a sledgehammer fix: disable “Generate Serialization Assembly” in the project file. But disabling something that may be valuable seems a little drastic just to appease a finicky build machine.

A better approach starts (as it always does) with getting more information about the failure. In TeamCity’s “All messages” view:

- This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem. (Exception from HRESULT: 0x800736B1)

If you would like more help, please type "sgen /?".
"sgen.exe" exited with code 1.

This yields the eminently googleable HRESULT 0x800736B1, which led to a couple of pages pinpointing the problem:

  • the project references a DLL that depends on the C++ runtime library
  • sgen.exe needs to load referenced DLLs
  • loading a C++ DLL causes it to load the C++ runtime
  • The C++ runtime exists on my machine because it has Visual Studio installed; the build machine doesn’t.

Solution: install vcredist_x86. The build is now fine.

I’m quite excited about TeamCity; go check out their early access program!

Comments are closed.