Rev
Rev

Reputation: 6092

Target "Any CPU" with "Prefer 32-bit" disabled gets compiled with 32-bit preference anyway

I set my target to "Any CPU" with "Prefer 32-bit" disabled.

enter image description here

I wondered why my process is still running as 32-bit on a 64-bit system, so I checked CorFlags. It confirms, that my executable gets compiled with 32BITPREF enabled.

enter image description here

What would cause this?

Upvotes: 1

Views: 679

Answers (1)

Rev
Rev

Reputation: 6092

I checked the project file to see what <Prefer32Bit> was actually set to, but oddly it wasn't explicitly specified at all.

So VS obviously defaults to <Prefer32Bit> to trueif the tag isn't present, which is consistent with respect to What AnyCPU Really Means As Of .NET 4.5 and Visual Studio 11:

In .NET 4.5 and Visual Studio 11 the cheese has been moved. The default for most .NET projects is again AnyCPU, but there is more than one meaning to AnyCPU now. There is an additional sub-type of AnyCPU, “Any CPU 32-bit preferred”, which is the new default...

Adding <Prefer32Bit>false</Prefer32Bit> manually solved the issue.

No idea why the tag was missing in the first place. Maybe the project was updated from a pre .Net Framework 4.5 version and VS missed to add when performing the project update?

But not setting the "Prefer 32-bit" checkbox when the tag is missing seems to be an oversight from VS.

Upvotes: 3

Related Questions