tony
tony

Reputation: 853

Visual Studio 2010/2012: 32 or 64 bit?

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?

Upvotes: 3

Views: 7043

Answers (3)

Hans Passant
Hans Passant

Reputation: 941417

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.

Upvotes: 3

user7116
user7116

Reputation: 64068

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.

Upvotes: 5

SLaks
SLaks

Reputation: 887415

"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)

Upvotes: 8

Related Questions