What does the Visual Studio “Any CPU” target mean?

Submitted by admin on Wed, 08/03/2016 - 21:32

What is the "Any CPU"?

What is the "Any CPU" compilation target, and what sort of files does it generate? I examined the output executable of this "Any CPU" build and found that they are (who would not see that coming!) the x86 executables. So, is there any the difference between targeting executable to x86 vs "Any CPU"?


Check out the article Visual Studio .NET Platform Target Explained.

The default setting, "Any CPU", means that the assembly will run natively on the CPU it is currently running on. Meaning, it will run as 64-bit on a 64-bit machine and 32-bit on a 32-bit machine. If the assembly is called from a 64-bit application, it will perform as a 64-bit assembly and so on.


in other words:

 An AnyCPU assembly will JIT to 64 bit code when loaded into 64 bit process and 32 bit when loaded into a 32 bit process.
By limiting the CPU you would be saying there is something being used by the assembly (something likely unmanaged) that requires 32 bits or 64 bits.