.net - sgen.exe生成错误 “Unable to load one or more of the requested types”

标签 .net visual-studio-2012 sgen

我正在构建一个包含几个解决方案的解决方案。除了其中一个以外,其他所有构建都没有任何问题。有问题的发出以下消息:

Error 2 Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. J:\MyPlugins\MyPlugin1\SGEN MyPlugin1

I turned on the verbose output in Visual Studio and I got the following: C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\sgen.exe /assembly:



我使用FusionLog检查了输出,并正确加载了所有内容。原来这是一条红鲱鱼。我决定在显示详细信息的情况下再次运行该构建。我得到以下内容:

Microsoft (R) Xml Serialization support utility [Microsoft (R) .NET Framework, Version 4.0.30319.17929] Copyright (C) Microsoft Corporation. All rights reserved. If you would like more help, please type "sgen /?". SGEN : error : Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. The command exited with code 1. Done executing task "SGen" -- FAILED.

C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\sgen.exe /assembly:":\MyPlugins\MyPlugin1.dll" /proxytypes /reference:"J:\MyPlugins\MyPlugin1\packages\FluentValidation.3.4.6.0\lib\Net40\FluentValidation.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\mscorlib.dll" /reference:"J:\MyPlugins\MyPlugin1\Libraries\Core\bin\Release\Core.dll" /reference:"J:\MyPlugins\MyPlugin1\Libraries\Services\bin\Release\Services.dll" /reference:"J:\MyPlugins\MyPlugin1\Presentation\Web.Framework\bin\Release\Web.Framework.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\System.Data.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\System.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\System.EnterpriseServices.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\System.Web.dll" /reference:"C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Assemblies\System.Web.Mvc.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\System.Web.Services.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\System.Xml.dll"



是什么导致此错误,以及如何在不关闭SGEN的情况下解决该错误?仅供引用,我没有编写代码。

最佳答案

一个对我有用的很棒的技巧,摘自:http://hashtagfail.com/post/5255977780/sgen-loaderexceptions-error

The reason why this happens is that in Release builds, Visual Studio attempts to generate a serialization assembly containing the types in your solution, to improve XmlSerializer serialization performance, should you choose to serialize your types. This can be disabled by going to the Build tab of the project properties and setting “Generate serialization assembly” to “Off”.

关于.net - sgen.exe生成错误 “Unable to load one or more of the requested types”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14372195/

相关文章:

c++ - 如果我不使用 vs110_xp 编译 DLL 会怎样?

c# - 为特定更新禁用 FileSystemWatcher?

c# - 如何从 UI 自动化模式提供程序返回错误?

c# - 在 ASP.NET MVC 中运行时加载程序集的权限

.net - MVC3项目升级到VS2012后出现AccessViolationException

c++ - 使用 OpenCV 2.4.8 构建 CUDA 5.5

visual-studio-2010 - VS.NET 2010/MSBUILD 可以为 .NET 3.5 SP1 生成 XmlSerializers 吗?

visual-studio-2010 - VSTS 2010 SGEN : error : Could not load file or assembly (Exception from HRESULT: 0x80131515)

.net - SGEN、InternalsVisibleTo 和程序集签名

c# - 如何使用 C# .NET 4.5 将文件从 ZIP 存档读取到内存而不先将其解压缩到文件?