问题描述
我只是最近一VS2008 / .NET 3.5 SP1项目升级到Visual Studio 2010和.NET 4,我有一个生成后事件,呼吁SGEN产生XmlSerializers组装。
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 /?".
我得到的命令行运行SGEN同样的错误,但我想不出是什么问题。任何想法?
I get the same error running SGEN from the command line, but I can't figure out what the problem is. Any ideas?
推荐答案
是的,有sgen.exe两个版本,一个是CLR V2组件,其它为CLR v4的组件。它的炸弹,因为你问sgen.exe的V2版本来处理V4组件。
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.
如何检查你的项目被sgen.exe开始。如果它是一个生成后事件,那么你就必须要调整到sgen.exe的路径。我没有看到宏或环境变量的监督向右自动获得它,有点。
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.
这篇关于SGEN升级从VS2008到VS2010后无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!