从VS2008升级到VS2010后SGEN不起作用

发布于 2024-08-31 02:30:27 字数 852 浏览 6 评论 0原文

我最近刚刚将 VS2008/.NET 3.5 SP1 项目升级到 VS2010 和 .NET 4。我有一个生成后事件,它调用 SGEN 来生成 XmlSerializers 程序集。

每当我尝试运行它时,我都会收到以下错误。

"C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\sgen.exe" /debug /force /verbose /c:"platform:x86" "C:\path\to\SomeAssembly.dll"
Microsoft (R) Xml Serialization support utility
[Microsoft (R) .NET Framework, Version 2.0.50727.3038]
Copyright (C) Microsoft Corporation. All rights reserved.
Error: An attempt was made to load an assembly with an incorrect format: c:\path\to\someassembly.dll.
  - Could not load file or assembly 'file:///c:\path\to\someassembly.dll'
or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

If you would like more help, please type "sgen /?".

我从命令行运行 SGEN 时遇到相同的错误,但我无法弄清楚问题是什么。有什么想法吗?

I just recently upgraded a VS2008/.NET 3.5 SP1 project to VS2010 and .NET 4. I have a post-build event which calls SGEN to generate the XmlSerializers assembly.

Whenever I try to run it I get the following error.

"C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\sgen.exe" /debug /force /verbose /c:"platform:x86" "C:\path\to\SomeAssembly.dll"
Microsoft (R) Xml Serialization support utility
[Microsoft (R) .NET Framework, Version 2.0.50727.3038]
Copyright (C) Microsoft Corporation. All rights reserved.
Error: An attempt was made to load an assembly with an incorrect format: c:\path\to\someassembly.dll.
  - Could not load file or assembly 'file:///c:\path\to\someassembly.dll'
or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

If you would like more help, please type "sgen /?".

I get the same error running SGEN from the command line, but I can't figure out what the problem is. Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

故笙诉离歌 2024-09-07 02:30:27

似乎 SGEN 的第二行输出很重要:

[Microsoft (R) .NET Framework, Version 2.0.50727.3038]

我发现了 SGEN 的另一个版本,它似乎可以在 C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\sgen.exe 中工作。当您运行它时,它会输出以下内容:

[Microsoft (R) .NET Framework, Version 4.0.30319.1]

我不确定为什么两者都包含在 Windows 7 SDK 中...

Seems like that second line of output from SGEN is important:

[Microsoft (R) .NET Framework, Version 2.0.50727.3038]

I found another version of SGEN which seems to work at C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\sgen.exe. It outputs this when you run it:

[Microsoft (R) .NET Framework, Version 4.0.30319.1]

I'm not sure why both are included in the Windows 7 SDK...

蔚蓝源自深海 2024-09-07 02:30:27

是的,sgen.exe 有两个版本可用,一种用于 CLR v2 程序集,另一种用于 CLR v4 程序集。它会爆炸,因为您要求 v2 版本的 sgen.exe 处理 v4 程序集。

检查您的项目如何启动 sgen.exe。如果这是构建后事件,那么您必须调整 sgen.exe 的路径。我没有看到宏或环境变量可以自动使其正确,有点疏忽。

Yes, there are two versions of sgen.exe available, one for CLR v2 assemblies, the other for CLR v4 assemblies. It bombs because you ask the v2 version of sgen.exe to process a v4 assembly.

Check how your project gets sgen.exe started. If it is a post-build event then you'll have to tweak the path to sgen.exe. I don't see a macro or environment variable to get it right automatically, bit of an oversight.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文