(renamed from "Why does my c# project build successfully under Debug/x64, but fail under Release|x64?") Here's my problem...
One of the projects in my solution builds just fine under Debug|x64, but when I switch to Release|x64, my build fails (both locally and on my CI build server) with the following error:
An attempt was made to load an assembly with an incorrect format: C:\Projects\MyCompany\Branches\Trunk\MyCompany.Platform\src\MyCompany.Platform.AppServices\bin\x64\Release\MyCompany.Platform.AppServices.dll.
and the error is apparently coming from this file: C:\Projects\MyCompany\Branches\Trunk\MyCompany.Platform\src\MyCompany.Platform.MyApi\SGEN
The project that's failing to build is a wrapper around a WebService API (the project contains a .Net 2.0 web reference to the service), in case that might matter. Oh, and the AppServices project (the one that's failing to load) is just a pure managed .Net 4.0 project/assembly.
BTW, I'm on Visual Studio 2010, on a 64-bit machine, and all projects are targeting .Net framework 4.0.
So can anyone tell me why this is happening?
UPDATE: From a bit of google-based research, it looks like the solution is to force Visual Studio and MSBuild to use the 64-bit version of the SGEN tool, but I don't really know how to do that (and the various examples I saw both here on StackOverflow and other websites seemed to be either missing an intermediate step or just some general explanations). Can anyone show me how to force it to use x64 SGEN?