I am using C#. If I create a solution in Visual Studio 2010 or 2012 I get a default configuration Debug/Release and Platform "Any CPU". Am I creating a 32 or a 64 bit application?
-
"Any CPU" will run as either 32- or 64-bit depending on the platform you're running on. – Joachim Isaksson Feb 15 '13 at 18:50
-
2I'm not clear on why this question is getting voted down so much. It's based on a misunderstanding...but pretty much any question on this site is based on a lack of knowledge in one area or another. – Beska Feb 15 '13 at 18:53
-
Usually you should choose "AnyCPU" for all your class library assemblies, and then decide FOR INDIVIDUAL EXCUTABLE assemblies whether you want them to be 32 bit, 64 bit, or AnyCPU. The exception is any class libraries that use 32-bit or 64-bit unmanaged DLLs, which must then be set appropriately. We isolate all such assemblies. – Matthew Watson Feb 15 '13 at 19:25
3 Answers
"Any CPU" means exactly what it says: Any CPU.
It will run as the native bitness of the OS.
If you check Prefer 32-bit
, it will run as x86 on x86-64 platforms.
(but it will still be able to run as ARM)

- 868,454
- 176
- 1,908
- 1,964
You're creating a .Net executable that will run on either 32 bit or 64 bit machines in either a 32 or 64-bit context. This actually matters quite a bit if you are using unmanaged resources!
For instance, if you are compiling for AnyCPU but utilize a 32 bit DLL, your application will crash on 64-bit machines.
You have to watch out, the Platform setting for a configuration doesn't actually select a platform in a C# project. This confusion stems from C++ being integrated in Visual Studio, an IDE where the setting does matter.
The relevant setting is controlled by a project property. Project + Properties, Build tab, Platform target combobox. Which defaults to x86 for VS2010 projects, the "Prefer 32-bit" option is ticked for VS2012 projects. You can pick AnyCPU and untick the Prefer 32-bit option for your EXE project to get a 64-bit process. The implication is that this setting does not necessarily match with your configuration's Platform setting. This has caused a great deal of confusion.

- 922,412
- 146
- 1,693
- 2,536