"sgen.exe" exited with code 1 RRS feed

  • Question

  • I am trying to build a project in VS 2005 but I am getting the error:

    Error 67 "sgen.exe" exited with code 1. C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets 1892 9 TAI.Util

    This project had been building just fine earlier today. The only thing that happened between is I refreshed the web references in this project. As a test I added the same web references to a new project and it builds just fine.

    Wednesday, December 28, 2005 11:21 PM


  • I seem to get the same message when I update the web references in the project. Removing the project from the solution and readding it seems to fix the problem.
    Tuesday, January 3, 2006 7:49 PM

All replies

  • Have you tried building with Detailed or Diagnostic verbosity?  It seems that the error is certainly related to the generation of serialization assemblies for use with the web service. 

    Try building with a higher verbosity and see if that reveals more information.  Let us know what you find.


    Faisal Mohamood
    Program Manager - MSBuild

    Thursday, December 29, 2005 5:31 PM
  • Thanks for the quick response.

    VS does the build so I'm not sure how to change the verbosity or view the messages it produces. I don't use MSBuild directly, but knowing how to view the messages may prove useful in the future.

    Since my original post, I managed to get the solution to build again by removing and re-adding the project that contains the web references.


    Thursday, December 29, 2005 5:39 PM
  • You can customize the output from
    Then go to Projects and Soutions and click on Build and Run
    The MSBuild verbosity is the last drop down on that dialog box.

    Sayed Ibrahim Hashimi
    Thursday, December 29, 2005 6:21 PM
  • Thanks. I'm still getting used to the VS 2005. I'll give it a try.
    Thursday, December 29, 2005 6:22 PM
  • Hi,

    I still get the same error after changing the verbosity level. Is there any other workaround.




    Tuesday, January 3, 2006 7:13 PM
  • Can you insert the relevant portions of the log here?

    Sayed Ibrahim Hashimi
    Tuesday, January 3, 2006 7:15 PM
  • Error 1 "sgen.exe" exited with code 1. C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets 1892 9 IASTCFrameWork.Net

    It looks like a bug in VS 2005.

    Tuesday, January 3, 2006 7:47 PM
  • I seem to get the same message when I update the web references in the project. Removing the project from the solution and readding it seems to fix the problem.
    Tuesday, January 3, 2006 7:49 PM
  • Hi,

    It worked after removing the reference and added back again to the solution, but i still feel that this a bug in the conversion tool.


    Tuesday, January 3, 2006 8:11 PM
  • I have this problem in a solution that has one converted web site project and a new class library project. The web references are in the class library project.
    Tuesday, January 3, 2006 8:13 PM
  • Mahesh, Birch,

    What exactly is your project structure? Are you doing an ASP.NET website, webservice, or something else? Were the projects originally created in Visual Studio 2003 and then upgraded to 2005? We need as much detail as you can provide on the projects in your solution so we can figure out which team needs to investigate this.


    Wednesday, January 4, 2006 5:32 PM
  • Thanks for digging into this.

    The project started in VS 2003 (maybe even the version before that).

    In VS 2003 the solution consisted of a single webproject. It had 5 web references to web services published by a Java/BEA system all of which are internal to the company. These web services are for CRUD operations on the systems database.

    I used the Convert "Wizard" in VS 2005 to upgrade the entire solution to 2.0. After the conversion I broke the solution into two seperate projects. One contains just the aspx pages. The other is a newly created Class Library project. All of the web references were moved to the second project.

    I'd be happy to send you any of the files that would be useful for you to look at (although I don't see a way to include files through this page.)

    Wednesday, January 4, 2006 6:12 PM
  • Hi,

    I resolve the problem, I think.

    You must set your output path in to bin\debug directory project

    in other mode you must use another security settings





    Sunday, January 8, 2006 6:18 PM
  • I'm also experiencing a similar problem. When i change the build options in the ConfigurationManager, i often get this error. The only way I've found to fix the problem has been to exit and restart Studio or, in some cases, to remove and re-add the project.

    I'm working with a solution that has 4 web projects and 3 project references, all written in 1.1 and converted to 2.0 using the wizard.

    Friday, January 20, 2006 3:20 PM
  • I just ran into the exact same issue today.  We have a 19-project solution, and this particular project, the so-called "vital organs", was causing issues once we changed the configuration to Release.  Exiting Visual Studio didn't help, and neither did removing and re-adding the project.  We just added a web reference today, so I wonder if that's part of the issue.  I didn't find any other resource, so I'm kind of stuck in Debug Mode for now...
    Friday, January 20, 2006 11:39 PM
  • I don't know why, but I haven't been experiencing this problem since my last post. I haven't changed anything with my procedures other than maybe using the Clean and Rebuild instead of just Build for the project. Have you tried the Clean/Rebuild when experience the problem?
    Monday, January 23, 2006 8:27 PM
  • I received the same problem with a VS2005 project utilizing Web References.  I only get the sgen.exe error when the project is compiled in release mode.  When it is switched to Debug Mode, it compiles fine.



    Friday, January 27, 2006 4:47 PM
  • The only resolution I found was to compile the project using the Web Reference in Debug mode.  Since we obfuscate the entire solution, it isn't vital for that particular project to run in release mode.  Your situation may be different, though.
    Friday, January 27, 2006 5:19 PM
  • Hi,

    I have been with the same problem the last days. Last but not least i found the solution, at least for my case. I could compile in debug mode, not in release. The problem comes with the web reference when it appears in the project. Well, if you see the folder where your assembly is located, surely you will have a file like this: YourAssembly.XmlSerializers.dll.

    I founded this on http://primates.ximian.com/~lluis/blog/archives/archive_2004-m07.php

    There is also a new tool called sgen. If you run "sgen myassembly.dll" it will generate a new assembly called myassembly.XmlSerializers.dll that contains all serializers for all classes inside myassembly. When an application wants to serialize an object from myassembly, it will load the serializer from myassembly.XmlSerializers.dll. The goal of all this stuff is to avoid the cost of generating and compiling the serializers on the fly.

    The solution? Well, you can go to properties-build-generate serialization assembly and set to off this property, or each time you want to buid the project in release mode, delete de XmlSerializers.dll file you should find in the folder.

    Saludos/Kind Regards


    Friday, February 17, 2006 11:01 AM
  • I am having exactly the same problem. I've got a solution with about 15 projects, one of which is throwing this 'sgen.exe exited with code 1' error.

    It has 4 web-references, which I've removed and re-added, but it still comes up with this error.

    I have changed to a high verbosity, and now have a massive text file.. I could email it if that helps you ?

    Please help, I'm stuck.



    Friday, February 24, 2006 3:07 AM

    Found this solution at http://blogs.vizibility.net/sdobrev/archive/2006/04/21/212.aspx:

    If you are having this problem while building your VS.NET 2005 project in Release mode here is the solution:

    Go to the project properties. Click on the build tab and set the value of the "Generate Serialization Assembly" dropdown to Off.

    P.S. If you wonder for what is this sgen.exe here is explanation from the msdn: "The XML Serializer Generator creates an XML serialization assembly for types in a specified assembly in order to improve the startup performance of a XmlSerializer when it serializes or deserializes objects of the specified types."

    Worked like a charm!

    Wednesday, June 28, 2006 1:37 PM
  • Myself and one of my devs experienced a similar issue.  In our case it worked great in debug builds, but failed in release builds.

    Here's what helped for us:

    In the output window the command line is echoed.  Copy that command line to a command prompt in the project folder adding a /k to the command line to preserve the temporary files.

    The temporary files have random names so look for a .out file and that will be the actual output from sgen.exe.

    In our particular case it appeared that sgen was attempting to overwrite a pre-existing assembly.  We knew there were none in the bin folder so we were puzzled.  The output showed us that sgen was ignoring the explicit path in the /assembly parameter and instead trying to generate based off an earlier version which resided in the GAC.  When we removed the instance of the assembly from the GAC everything worked great.

    Hope that helps.

    Wednesday, August 30, 2006 3:41 PM
  • If you are getting this error message, check your folder settings. Sometimes if you do not have access on the target folder, VS2005 exits the command line with this error code.




    Monday, September 25, 2006 8:29 AM
  • I received this error and diagnosed the problem as follows:


    I have three different solutions with various projects in them.  As an example, assume that I have three solutions, A, B, and C.

    Projects in Solution B reference libraries build in Solution A. Projects in Solution C reference libraries built in solution B and solution A. Some of the libraries referenced in Solution B also reference projects in Solution A.

    I was getting the error rebuilding a project in Solution C.   I finally diagnosed the problem to be that I had recompiled Solution A but not solution B.  Since C was referencing libraries in both A and B, the sgen.exe could not load the output of C, since the dependencies were conflicting, the project in C wanted one version of a library in A and a library from B wanted a different version of the same library from A.

    After getting all of the dependent libraries compiled in the correct order, the error went away.

    Hope this helps.


    Friday, October 6, 2006 6:06 PM
  • More info on sgen.exe and why it fails. Read it here:


    Monday, October 30, 2006 11:41 PM
  • Seems to be related to the development web server that runs in the system tray. I just closed all the web servers running in the system tray and the error went away without removing the project from the solution.
    Tuesday, February 13, 2007 6:13 PM
  • Wednesday, March 28, 2007 4:02 PM
  • Disabling the generation of serialization assemblies works, however, this option is not available for VB Projects. To make this work for VB Projects:
    Add the tag
    in the .vbproj file after the line
        <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    Friday, June 22, 2007 1:37 PM
  •  Ans Vlug wrote:
    Disabling the generation of serialization assemblies works, however, this option is not available for VB Projects. To make this work for VB Projects:
    Add the tag
    in the .vbproj file after the line
        <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">


    This worked perfectly for me.

    The .vbproj File had the GenerateSerializationAssemblies option to Auto for both Release and Debug builds.

    Sgen always exited with Code 1 because he couldn't overwrite the existing xy.XmlSerializers.dll

    I could make him compile by deleting the xy.XmlSerializers.dll, but that's no solution at all.


    greetings Tigraine

    Monday, June 25, 2007 11:35 AM
  • I was having trouble building a solution in VIsual Studio 2005 and I was getting the following error.

    "sgen.exe" exited with code 1  

     I found that following the steps below fixed it:

    Open up the project properties.
    Open up the build tab.
    Set "Generate Serialization Assembly" to "Off"
    Wednesday, August 8, 2007 11:13 AM
  • I have exactly the same problems, when i use the release config the problem appears, then i switch the Serialization Assembly Generation to Off and works, but it breaks the app, sometimes when you use web services some of the request generated by the proxy must be serialized, and the with the option off the app throws an exception telling you that can't generate an XML file, I'm using VSTS SP1, any ideas??
    Monday, August 13, 2007 6:56 PM
  • Do Clean Solution and Rebuild the Solution.

    Thursday, November 15, 2007 3:59 PM
  • when you try to build a release version it gives an error/* "sgen.exe" exited with code 1 */

    From solution explorer right click the project ->properties  ->build tab->set generate serialization assembly to off

    Sunday, January 6, 2008 12:50 PM
  • I got this issue with my 2005 web project (started as a 2005), after I added a custom web control to the web application project.  I also added a Toolbox reference to the new class in the solution and the next time I built the project, I got this error.  I tried restarting VS but that did not work.  What did work was changing the output directory by adding the "Debug" suffix.  I think that some DLL in volved with serialization of the project is causing the issue and this "sgen.exe" does not like it.  When I deleted all the DLL's in the "bin\" folder, I was able to restore the proper output directory.  Hope this helps.


    - Rashad Rivera



    • Proposed as answer by Rashad Rivera Saturday, July 25, 2009 11:47 PM
    Wednesday, January 16, 2008 5:38 PM
  • I was also facing the same error in VS2005 for WebReference in the  Project.I removed the assembly registered in GAC(Global assembly Cache) and tried building the Project and it worked fine for me.

    Friday, February 15, 2008 9:20 AM
  • This helped my issue!  Thanks!  I had the DLL GAC'd before adding the web reference, and so the GAC'd version was conflicting with the one being built.  I removed the GAC'd version and it built fine, and I

    re-added mine to the 2.0 GAC


    Chad Laucher


    Tuesday, May 20, 2008 6:51 PM
  • >>Disabling the generation of serialization assemblies works, however, this option is not available for VB Projects

    Yes, in VS2005 it is available.

    On the project properties, choose Compile, then click the Advanced Compile Options button.  Generate Serialization Assemblies is the 2nd option from the bottom.
    Wednesday, July 16, 2008 5:40 PM
  • Hi!

    Assuming you have a problem with permissions with a shared reference, you may have to trust the shared directory using the caspol utility. (The sgen has this error when it can't get the good permissions)

    You may find usages and more informations following this link : http://blogs.msdn.com/shawnfa/archive/2004/12/30/344554.aspx


    Wednesday, October 1, 2008 10:10 AM
  • Like the posts above state, sgen.exe generates a DLL. It will be named [your assembly name].XmlSerializers.dll. Simply delete the dll.

    Once I increased the build verbosity I searched for sgen. In that section it stated that it could not generate [assemly name] because it already existed.
    Thursday, November 6, 2008 2:53 PM
  • Hi Adolfo,

    Thanks a lot.This post is awesome.Its worked for me.I was facing this issue from last couple of days & it was very painful for me.Now i just came out from this problem.The main culprit was XmlSerializers.dll. Thanks again....Cheers..!!

    Best Regards

    Goutam Patari (SE)
    • Proposed as answer by JesusLovesU Monday, September 28, 2009 6:02 AM
    Monday, March 30, 2009 2:11 PM
  • Hi All

    The below solutions worked for me. This is the best solution.

    Like the posts above state, sgen.exe generates a DLL. It will be named [your assembly name].XmlSerializers.dll. Simply delete the dll.

    Once I increased the build verbosity I searched for sgen. In that section it stated that it could not generate [assemly name] because it already existed.

    Monday, September 28, 2009 6:03 AM
  • The option to turn off serialization assembly generation is available in your project Properties | Compile. Click the "Advanced Compile Options" button. This is true for both VS2005 and VS2008.

    Wednesday, October 7, 2009 3:30 PM
  • @RichardUMG

    Yep.. It works...

    Tuesday, June 1, 2010 11:42 AM
  • Hi everyone, in my case i had a project with one Web Reference. For security reasons, i changed some classes´s scope (from Public to Friend). When set back those keywords the project compiles fine again. That´s all.
    Friday, October 8, 2010 6:58 PM
  • I had this same problem, that I would have to log out and then log back in and startup VS again.


    The code would run until I changed it, then I would generate the "used by another process error".


    After I made a few ajustments, the code does no longer generate the error. See if this helps:




    a) Make sure that the application is no being closed more than once (like an Application.Close() call in both the Program.cs and the form1.cs code)


    b) Make sure that the forms are not closed more than once, such as Form1.ActiveForm.Close() being called twice.


    c) Make sure that all of the program endings are called by an Application.Exit(); command.


    Fixing these helped me, and hopefully will help you.




    P.S. By the way, if you just hide the forms, they will automatically close at the program end.

    • Proposed as answer by DaMan92 Friday, October 8, 2010 9:03 PM
    Friday, October 8, 2010 9:02 PM
  • Hej,

    I just went to the project properties, then to the category "build" and set the Generate Serialization Assembly off.

    Hope this help

    Friday, August 24, 2012 9:25 AM
  • This could be cause when you try to build a project targeted to x64 in a x86 system just right click the project click on build and change the target platform to any CPU. hope this helps anyone who may have this issue
    • Proposed as answer by birkoff himura Monday, October 8, 2012 6:11 PM
    Monday, October 8, 2012 6:11 PM
  • That helped me figure out what's going on. This is a msbuild vs xbuild bug:

    xbuild WebServicesNotWorking.sln /p:Configuration=Release (Works)
    msbuild WebServicesNotWorking.sln /p:Configuration=Release (Your error).


    1. Use XS instead of VSfM
    2. Uncheck Preferences -> Projects -> Build -> Build with MSBuild instead of xbuild (I don't recommend this as it may affect other things)
    3. Build the project with xbuild and check in the output for now.
    Monday, October 9, 2017 5:25 AM