开发者

.NET Software running on x64 but compiled on x86 for Any CPU (VS2008)

I have a problem, whereby I’m getting runtime errors with a compiled program. This works fine in the development environment (x86), but not on the production environment (which is x64).

I found this article, which seems to imply that compiling the software as Any CPU may run the software as x64 software if it’s run in a 64 bit environment.

Is this the case, and if so, should software ever be compiled under Any CPU (as it seems to make for a mismatch between the tw开发者_如何学Co environments)?


AnyCPU is great if you are using managed code only. Managed code can be executed in a 32-bit-process or 64-bit-process. With AnyCPU, the framework chooses the bitness native to the OS.

The same is not true for unmanaged code. It needs to be compiled either as 32-bit or 64-bit code. Of course, due to the WoW64 subsystem, 64-bit Windows can run 64-bit processes.

But 64-bit processes cannot load 32-bit modules (DLLs, OCXs, etc.).

That means if your program is using unmanaged modules of some kind, better make sure to set the bitness manually so that all components have the same bitness.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜