Coder Perfect

What is the purpose of Visual Studio’s “Prefer 32-bit” setting, and how does it work?

Problem

I’m not sure how the compiler will recognize when it’s time to compile for 64-bit when it’s needed. How does it know when it’s safe to go for 32-bit?

I’m particularly interested in how the compiler determines which architecture to target while compiling. Is it capable of analyzing the code and making a conclusion depending on what it discovers?

Asked by Aaron

Solution #1

What AnyCPU Really Means As Of.NET 4.5 and Visual Studio 11: Microsoft has a blog article What AnyCPU Really Means As Of.NET 4.5 and Visual Studio 11: Microsoft has a blog entry What AnyCPU Really Means

Answered by Lex Li

Solution #2

Here’s a straightforward response:

AnyCPU-32bitPreferred is only accessible in.Net 4.5 and later.

Answered by Yousha Aleayoub

Solution #3

If you don’t want to utilize extra memory with 64-bit applications, this is the explanation. That is, if your application is AnyCPU, you should run it in 32-bit mode.

To add to that, Visual Studio has a setting that targets a specific CLR:

Please see the article 64-bit Applications for further information (MSDN).

Answered by Peru

Post is based on https://stackoverflow.com/questions/12066638/what-is-the-purpose-of-the-prefer-32-bit-setting-in-visual-studio-and-how-does