"sgen.exe" exited with code 1
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.
答案
- 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.
全部回复
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.
Thanks.
Faisal Mohamood
Program Manager - MSBuildThanks 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.
- You can customize the output from
Tools->Options
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
www.sedodream.com - Thanks. I'm still getting used to the VS 2005. I'll give it a try.
Hi,
I still get the same error after changing the verbosity level. Is there any other workaround.
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.
- 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.
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.
- 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.
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.
Neil
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.)
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
bye
Nino
info@ninocrudele.net
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.
- 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...
- 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?
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.
Help?
- 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.
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
Adolfo
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.
Thanks
Rich.
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!
- 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.
Cheers,
Colin 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.
Cheers,
Rizwan
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.
Metro.
More info on sgen.exe and why it fails. Read it here:
http://blogs.vizibility.net/sdobrev/archive/2006/10/31/sgen.exe-continued.aspx
- 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.
Hi,
I found the solution on http://www.sharepointblogs.com/mykiep/archive/2007/03/06/sgen-exe-exited-with-code-1.aspx
Good luck!
- 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
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
in the .vbproj file after the line
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> 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
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
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
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"- 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??
Do Clean Solution and Rebuild the Solution.
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
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
- 已建议为答案Rashad Rivera 2009年7月25日 23:47
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.
- 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
- >>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.
- 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
Regards,
Hervé
- 已编辑Hervé Soulié 2008年10月1日 10:13
- 已编辑Hervé Soulié 2008年10月1日 10:14
- 已建议为答案Hervé Soulié 2008年10月1日 10:15
- 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. - 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)
Pune,India- 已建议为答案JesusLovesU 2009年9月28日 6:02
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.- 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.
Richard

