Dzyann
Dzyann

Reputation: 5208

Why is the checkbox 'Prefer 32-bit' disabled in Visual Studio 2012?

I came across a situation in which I would like to set the Prefer 32-bit to true. But in Visual Studio 2012, it is showing as disabled. And no matter what I do it doesn't get enabled.

I read that Any CPU with Prefer 32-bit is the default value for all new projects. So, should I assume that although it is disabled it is set to true? Then how can you set it to be just Any CPU?

In What AnyCPU Really Means As Of .NET 4.5 and Visual Studio 11 and in many other posts and questions here in Stack Overflow it says:

overall, there are now five options for the /platform C# compiler switch: x86, Itanium, x64, anycpu, and anycpu 32bit preferred

What's more, I have some collegues that have mentioned to me that in the past that checkbox was enabled (maybe they are wrong?).

Why is the Prefer 32-bit checkbox disabled, and how can I enable it again?

My processor is 64-bit, and I have applied the Update2 to Visual Studio 2012.

Upvotes: 50

Views: 38381

Answers (3)

NJS
NJS

Reputation: 506

This setting may also be disabled if your project is a unit test project. It turns out the setting wasn't my issue anyway. I got tests running by changing the Visual Studio test runner to run tests as a 64-bit process.

In Visual Studio Community 2015, I found this in the Test menu:
Test > Test Settings > Default Processor Architecture > X64

Here's more info from Microsoft:
https://msdn.microsoft.com/en-us/library/ee782531.aspx

Upvotes: 2

Matthew Watson
Matthew Watson

Reputation: 109577

Assuming you've got an executable project, then if you change your target platform to .NET 4.5, it should become enabled.

It's a .NET 4.5-only thing, and it's only enabled for executables.

Upvotes: 60

Ron Deijkers
Ron Deijkers

Reputation: 3101

In case anybody encounters this for a .NET 4.5 executable in Visual Studio 2013 (and possibly Visual Studio 2012):

We solved it by switching the project to .NET 4.0 and then back .NET 4.5 (on the Build tab of the project properties). This reenabled the checkbox "Prefer 32 bit" for AnyCPU.

Upvotes: 4

Related Questions