28

Just got the Visual Studio 11 developer preview installed. I see a new option in the project properties called "Prefer 32-bit" when compiling a managed (C#, VB) application with the AnyCPU target specified. This doesn't appear to be an option for class libraries, just top-level apps.

What does this flag indicate?

lightw8
  • 3,262
  • 2
  • 25
  • 35
  • 1
    You should refer to this post, http://blogs.microsoft.co.il/blogs/sasha/archive/2012/04/04/what-anycpu-really-means-as-of-net-4-5-and-visual-studio-11.aspx – Lex Li Aug 22 '12 at 05:36
  • 1
    Possible duplicate of [What is the purpose of the "Prefer 32-bit" setting in Visual Studio and how does it actually work?](https://stackoverflow.com/questions/12066638/what-is-the-purpose-of-the-prefer-32-bit-setting-in-visual-studio-and-how-does) – StayOnTarget Dec 04 '18 at 15:18
  • @DaveInCaz: How it can be a duplicate of a newer question? – IvanH Dec 05 '18 at 08:41
  • 2
    @IvanH according to StackOverflow guidance, "The general rule is to keep the question with the best collection of answers" https://meta.stackexchange.com/questions/10841/how-should-duplicate-questions-be-handled – StayOnTarget Dec 05 '18 at 11:23

4 Answers4

12

It likely indicates the app is AnyCpu but when 32 bit is available it shouold run as such. This makes sense - 64 bit apps use more memory, and sometimes you just dont need the memory space ;)

TomTom
  • 61,059
  • 10
  • 88
  • 148
  • 1
    64bit apps also cannot be debugged with edit and continue. Setting "Prefer 32-bit" hopefully enabled x64 users to debug the applications running on AnyCPU again without setting the target to x86/32bit compile. – CodingBarfield Sep 22 '11 at 07:27
  • 13
    This is not the correct answer. Please refer to http://blogs.microsoft.co.il/blogs/sasha/archive/2012/04/04/what-anycpu-really-means-as-of-net-4-5-and-visual-studio-11.aspx – Lex Li Aug 22 '12 at 05:37
  • 6
    Then why not post it as answer ;-) – Dr. Andrew Burnett-Thompson Jun 25 '14 at 11:11
  • 1
    @LexLi is correct, this answer is wrong, from the article they linked, "If the process runs on a 64-bit Windows system, it runs as a 32-bit process. IL is compiled to x86 machine code.", "The difference, then, between “Any CPU 32-bit preferred” and “x86” is only this: a .NET application compiled to x86 will fail to run on an ARM Windows system, but an “Any CPU 32-bit preferred” application will run successfully." – jrh Jul 17 '18 at 17:32
  • [Archive.org Link for now dead Microsoft article](https://web.archive.org/web/20120406144909/http://blogs.microsoft.co.il/blogs/sasha/archive/2012/04/04/what-anycpu-really-means-as-of-net-4-5-and-visual-studio-11.aspx) – jrh Sep 09 '20 at 23:18
2

EDIT: Application compiled with "Any CPU 32-bit preferred" is compatible with x86, x64 and ARM, while x86 is compatible only with x86, x64 and not ARM. For details see this.

Tomas Kubes
  • 23,880
  • 18
  • 111
  • 148
2

Here's right and simple answer:

Application arch.

Yousha Aleayoub
  • 4,532
  • 4
  • 53
  • 64
1

There is an good article at What AnyCPU Really Means As Of .NET 4.5 and Visual Studio 11.

The short answer to your question is "When using that flavor of AnyCPU, the semantics are the following:

If the process runs on a 32-bit Windows system, it runs as a 32-bit process. IL is compiled to x86 machine code. If the process runs on a 64-bit Windows system, it runs as a 32-bit process. IL is compiled to x86 machine code. If the process runs on an ARM Windows system, it runs as a 32-bit process. IL is compiled to ARM machine code. The difference, then, between “Any CPU 32-bit preferred” and “x86” is only this: a .NET application compiled to x86 will fail to run on an ARM Windows system, but an “Any CPU 32-bit preferred” application will run successfully."

Community
  • 1
  • 1
MBentley
  • 995
  • 10
  • 16
  • 1
    The content of your answer is correct, but I'm curious, why did you remove the nice bullet list formatting present in the original article? – jrh Jul 17 '18 at 17:34