.net – What does the Visual Studio “Any CPU” target mean

64-bitbuildnetvisual-studio-2008

I have some confusion related to the .NET platform build options in Visual Studio 2008.

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 the x86 executables (who would not see that coming!). So, is there any difference between targeting executable to x86 vs. "Any CPU"?

Another thing that I noticed, is that managed C++ projects do not have this platform as an option. Why is that? Does that mean that my suspicion about "Any CPU" executables being plain 32-bit ones is right?

Best Answer

An AnyCPU assembly will JIT to 64-bit code when loaded into a 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.