I have a project in C#, which references unmanaged third-party DLL (which is ChilkatDotNet2.dll, but it seems not to matter). The third-party DLL is delivered in 2 versions, x86 and x64. The project references the x86 version – processorArchitecture=x86 in the appropriate <Reference> element. It builds just fine in both Debug|Any CPU and Release|Any CPU.
Now I change the reference to x64 version of third-party DLL – processorArchitecture=AMD64. (Don’t ask me why, please :)). The Debug|Any CPU builds just fine again. But the Release|Any CPU fails with the error: An attempt was made to load an assembly with an incorrect format: ChilkatDotNet2.dll.
What could be the reason? I would think it’s because VS itself runs as 32-bit process (right?), but why does it build fine in Debug?
Well, the problem seems to have hidden in the fact the project was upgraded from older versions of VS (I suppose, starting from 2005). I have re-created it from scratch, added all necessary stuff, and it works! Moreover, it became IDENTICAL to the bad one, and this makes me insane: one works, another doesn’t.
So, I gave up since “the sun is rising? don’t touch anything there”. 🙂 Thanks to everyone who suggested options to try – I appreciate your efforts (+1).
Accepting my own answer to mark the thread as complete, but don’t vote it up – it doesn’t contain useful info…