Just got the Visual Studio 11 developer preview installed. I see a new option in the project properties called "Prefer 32-bit" when compiling a managed (C#, VB) application with the AnyCPU targe开发者_StackOverflowt specified. This doesn't appear to be an option for class libraries, just top-level apps.
What does this flag indicate?
It likely indicates the app is AnyCpu but when 32 bit is available it shouold run as such. This makes sense - 64 bit apps use more memory, and sometimes you just dont need the memory space ;)
EDIT: Application compiled with "Any CPU 32-bit preferred" is compatible with x86, x64 and ARM, while x86 is compatible only with x86, x64 and not ARM. For details see this.
Here's right and simple answer:
There is an good article at What AnyCPU Really Means As Of .NET 4.5 and Visual Studio 11.
The short answer to your question is "When using that flavor of AnyCPU, the semantics are the following:
If the process runs on a 32-bit Windows system, it runs as a 32-bit process. IL is compiled to x86 machine code. If the process runs on a 64-bit Windows system, it runs as a 32-bit process. IL is compiled to x86 machine code. If the process runs on an ARM Windows system, it runs as a 32-bit process. IL is compiled to ARM machine code. The difference, then, between “Any CPU 32-bit preferred” and “x86” is only this: a .NET application compiled to x86 will fail to run on an ARM Windows system, but an “Any CPU 32-bit preferred” application will run successfully."
精彩评论