0

Microsoft made the Any CPU option dependent on a property of prefer 32-bit (see here for example). Previously we could disable that on the options of the project.

Now, however, I can't find it in the project's properties.

Where is it hiding?

(To replicate: Create a new WPF project and disable the prefer 32-bit option. How to disable it, you ask? So do I.)

ispiro
  • 26,556
  • 38
  • 136
  • 291
  • What .NET version are you targeting? Is the OS 32- or 64-bit? Do you want to run your app as 32- or 64-bit? – mm8 Mar 07 '22 at 13:21
  • @mm8 .NET 6.0. OS is 64-bit. I want to run it as 64 on 64, and as 32 on 32. – ispiro Mar 07 '22 at 14:07
  • Then you should simply set the platform target to `Any CPU` and keep the default values. – mm8 Mar 07 '22 at 14:13
  • you really shouldn't worry too much unless you have native dependencies – Daniel A. White Mar 07 '22 at 14:20
  • LOL, 'new property' is more than a decade old, and has actually been disabled for new projects. – Poul Bak Mar 07 '22 at 14:22
  • I mean, it is false now. The reason, they made that weird thing, was that the first 64-bit CPUs actually were optimized to 32-bit. However this is no longer true, which is why they have removed that option. You can easily check your process in task manager, if it is 32-bit, it will have `(32-bit)` after the name. – Poul Bak Mar 07 '22 at 15:56

1 Answers1

3

If you want to run your .NET 6 app as a 64-bit processes on a 64-bit operating system and as a 32-bit process on a 32-bit machine, the only thing you need to do is to set the target platform to Any CPU.

When running the app you should then be able to confirm that the Environment.Is64BitProcess property returns true on a 64-bit system.

mm8
  • 163,881
  • 10
  • 57
  • 88