Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the purpose of the "Prefer 32-bit" setting in Visual Studio and how does it actually work?

People also ask

Can Visual Studio run on 32-bit?

32-bit versions# If you need to run a 32-bit version of VS Code, both a 32-bit Installer and Zip archive are available.

Which is better 64-bit or 32-bit Msbuild?

Simply put, a 64-bit processor is more capable than a 32-bit processor because it can handle more data at once. A 64-bit processor can store more computational values, including memory addresses, which means it can access over 4 billion times the physical memory of a 32-bit processor. That's just as big as it sounds.

What is x86 and x64 in Visual Studio?

x86 refers to a 32-bit CPU and operating system while x64 refers to a 64-bit CPU and operating system.


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

In .NET 4.5 and Visual Studio 11 the cheese has been moved. The default for most .NET projects is again AnyCPU, but there is more than one meaning to AnyCPU now. There is an additional sub-type of AnyCPU, “Any CPU 32-bit preferred”, which is the new default (overall, there are now five options for the /platform C# compiler switch: x86, Itanium, x64, anycpu, and anycpu32bitpreferred). When using the "Prefer 32-Bit" flavor of AnyCPU, the semantics are as follows:

  • 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.


Here's a simple answer:

Application arch.

Note: AnyCPU-32bitPreferred is only available in .Net version 4.5 and higher.