C# – sgen.exe x64 .net c# fails with “assembly with an incorrect format”

64-bitcsgenvisual studio

I have ws2008 x64 with vs2008.

When I set my vs to x64 (because I have 64bit dlls) and run compilation sgen says that

An attempt was made to load an assembly with an incorrect format

VS takse sgen from
C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\

and I think that it should take it from
C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\x64\

when i take 64bit version of sgen and put it into C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\ (replace 32bit version). I was able to compile.

What should I do to point to the correct version of sgen under vs.

Can I somehow configure solutinon platforms for one project to point to the correct sgens (for x86 to 32 bit and for x64 to 64 bit sgen version)?

Best Answer

Does this help you out? Take a look at the section where he uses sgen as a post build:

As a consequence you need to add the SGen command as a custom post-build event on the Build Events tab of your VS project properties:

"C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\sgen.exe" /force /assembly:"$(TargetPath)" /compiler:/keycontainer:VS_KEY_5EFB7881D71082EDCF85DBBFCD748B9A /compiler:/delaysign-