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?
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...