sgen.exe在构建期间失败

时间:2008-08-09 04:57:01

标签: c# visual-studio msbuild

更改visual studio项目的输出目录后,它开始无法构建错误,非常类似:

C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\bin\sgen.exe /assembly:C:\p4root\Zantaz\trunk\EASDiscovery\EASDiscoveryCaseManagement\obj\Release\EASDiscoveryCaseManagement.dll /proxytypes /reference:C:\p4root\Zantaz\trunk\EASDiscovery\EasDiscovery.Common\target\win_x32\release\results\EASDiscovery.Common.dll /reference:C:\p4root\Zantaz\trunk\EASDiscovery\EasDiscovery.Export\target\win_x32\release\results\EASDiscovery.Export.dll /reference:c:\p4root\Zantaz\trunk\EASDiscovery\ItemCache\target\win_x32\release\results\EasDiscovery.ItemCache.dll /reference:c:\p4root\Zantaz\trunk\EASDiscovery\RetrievalEngine\target\win_x32\release\results\EasDiscovery.RetrievalEngine.dll /reference:C:\p4root\Zantaz\trunk\EASDiscovery\EASDiscoveryJobs\target\win_x32\release\results\EASDiscoveryJobs.dll /reference:"C:\Program Files\Infragistics\NetAdvantage for .NET 2008 Vol. 1 CLR 2.0\Windows Forms\Bin\Infragistics2.Shared.v8.1.dll" /reference:"C:\Program Files\Infragistics\NetAdvantage for .NET 2008 Vol. 1 CLR 2.0\Windows Forms\Bin\Infragistics2.Win.Misc.v8.1.dll" /reference:"C:\Program Files\Infragistics\NetAdvantage for .NET 2008 Vol. 1 CLR 2.0\Windows Forms\Bin\Infragistics2.Win.UltraWinChart.v8.1.dll" /reference:"C:\Program Files\Infragistics\NetAdvantage for .NET 2008 Vol. 1 CLR 2.0\Windows Forms\Bin\Infragistics2.Win.UltraWinDataSource.v8.1.dll" /reference:"C:\Program Files\Infragistics\NetAdvantage for .NET 2008 Vol. 1 CLR 2.0\Windows Forms\Bin\Infragistics2.Win.UltraWinDock.v8.1.dll" /reference:"C:\Program Files\Infragistics\NetAdvantage for .NET 2008 Vol. 1 CLR 2.0\Windows Forms\Bin\Infragistics2.Win.UltraWinEditors.v8.1.dll" /reference:"C:\Program Files\Infragistics\NetAdvantage for .NET 2008 Vol. 1 CLR 2.0\Windows Forms\Bin\Infragistics2.Win.UltraWinGrid.v8.1.dll" /reference:"C:\Program Files\Infragistics\NetAdvantage for .NET 2008 Vol. 1 CLR 2.0\Windows Forms\Bin\Infragistics2.Win.UltraWinListView.v8.1.dll" /reference:"C:\Program Files\Infragistics\NetAdvantage for .NET 2008 Vol. 1 CLR 2.0\Windows Forms\Bin\Infragistics2.Win.UltraWinMaskedEdit.v8.1.dll" /reference:"C:\Program Files\Infragistics\NetAdvantage for .NET 2008 Vol. 1 CLR 2.0\Windows Forms\Bin\Infragistics2.Win.UltraWinStatusBar.v8.1.dll" /reference:"C:\Program Files\Infragistics\NetAdvantage for .NET 2008 Vol. 1 CLR 2.0\Windows Forms\Bin\Infragistics2.Win.UltraWinTabControl.v8.1.dll" /reference:"C:\Program Files\Infragistics\NetAdvantage for .NET 2008 Vol. 1 CLR 2.0\Windows Forms\Bin\Infragistics2.Win.UltraWinToolbars.v8.1.dll" /reference:"C:\Program Files\Infragistics\NetAdvantage for .NET 2008 Vol. 1 CLR 2.0\Windows Forms\Bin\Infragistics2.Win.UltraWinTree.v8.1.dll" /reference:"C:\Program Files\Infragistics\NetAdvantage for .NET 2008 Vol. 1 CLR 2.0\Windows Forms\Bin\Infragistics2.Win.v8.1.dll" /reference:"C:\Program Files\Microsoft Visual Studio 8\ReportViewer\Microsoft.ReportViewer.Common.dll" /reference:"C:\Program Files\Microsoft Visual Studio 8\ReportViewer\Microsoft.ReportViewer.WinForms.dll" /reference:C:\p4root\Zantaz\trunk\EASDiscovery\PreviewControl\target\win_x32\release\results\PreviewControl.dll /reference:C:\p4root\Zantaz\trunk\EASDiscovery\Quartz\src\Quartz\target\win_x32\release\results\Scheduler.dll /reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.configuration.dll /reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Design.dll /reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.DirectoryServices.dll /reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll /reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Web.dll /reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Web.Services.dll /reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll /reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /compiler:/delaysign- 
    Error: The specified module could not be found. (Exception from HRESULT: 0x8007007E)
    C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets(1902,9): error MSB6006: "sgen.exe" exited with code 1.

我将输出目录更改为target / win_x32 / release / results但是sgen中的路径似乎没有更新。在项目中似乎没有引用传递给sgen的路径,因此我不确定如何修复它。作为一种解决方法,我已禁用序列化生成,但修复底层问题会很好。有没有人见过这个?

5 个答案:

答案 0 :(得分:17)

如果在发布模式下构建VS.NET项目时遇到此问题,则解决方法是:

转到项目属性并单击“构建”选项卡,并将“生成序列化程序集”下拉列表的值设置为“关闭”。

Sgen.exe是“XML Serializer Generator为指定程序集中的类型创建XML序列化程序集,以便在序列化或反序列化指定类型的对象时提高XmlSerializer的启动性能。” (MSDN

答案 1 :(得分:7)

请参阅msdn了解sgen.exe的选项[你有命令行,你可以手动玩它...删除你的.XmlSerializers.dll或者使用/ force]

今天我还遇到了更多manually specify the sgen options的问题。我希望这不使用/ proxy开关,但它似乎可以让你指定输出目录。我不太了解msbuild让它变得很棒,但这应该让你开始[在你选择的非可视工作室编辑器中打开你的.csproj / .vbproj,看看底部你应该能够弄清楚如何/这里的情况]

[为方便起见,下面的代码已将UseProxyTypes设置为true]

<Target Name="GenerateSerializationAssembliesForAllTypes"
  DependsOnTargets="AssignTargetPaths;Compile;ResolveKeySource"
  Inputs="$(MSBuildAllProjects);@(IntermediateAssembly)"
  Outputs="$(OutputPath)$(_SGenDllName)">
    <SGen BuildAssemblyName="$(TargetFileName)"
      BuildAssemblyPath="$(OutputPath)" References="@(ReferencePath)"
      ShouldGenerateSerializer="true" UseProxyTypes="true"
      KeyContainer="$(KeyContainerName)" KeyFile="$(KeyOriginatorFile)"
      DelaySign="$(DelaySign)" ToolPath="$(SGenToolPath)">
        <Output TaskParameter="SerializationAssembly"
          ItemName="SerializationAssembly" />
     </SGen>
</Target>
<!-- <Target Name="BeforeBuild">
</Target> -->
<Target Name="AfterBuild"
  DependsOnTargets="GenerateSerializationAssembliesForAllTypes">
</Target>

答案 2 :(得分:0)

我没有看到这个特殊问题,但是最近我们发现“C1001:编译器发生了内部错误”cl.exe的类型崩溃在安装了一些随机和无关(或者我们认为)Windows之后得到了修复安全更新。

我们知道代码在使用相同版本和Service Pack级别的Visual Studio的其他计算机上没有崩溃,但是当我们尝试Windows安全更新时,我们真的抓住了吸管。

答案 3 :(得分:0)

对我来说这看起来很合理,除非有一些4096个字符的限制[你列出4020个字符]

对我来说4096的限制似乎有点荒谬,通过搜索命令行限制我发现的东西是2048或32767或8192。

答案 4 :(得分:0)

当我在GAC中的网站项目中引用了一个已卸载的程序集时,我遇到了这个问题,并且由于某种原因,该引用触发了序列化程序集生成,并且sgen在引用上被阻塞(因为它没有更长的存在)。删除引用并将序列化程序集生成转为关闭后,我不再有问题。