Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

visual studio 2010 - SGEN doesn't work after upgrading from VS2008 to VS2010

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 FilesMicrosoft SDKsWindowsv7.0Ainsgen.exe" /debug /force /verbose /c:"platform:x86" "C:pathoSomeAssembly.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:pathosomeassembly.dll.
  - Could not load file or assembly 'file:///c:pathosomeassembly.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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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 FilesMicrosoft SDKsWindowsv7.0AinNETFX 4.0 Toolssgen.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...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...