When I create a new WPF application in Visual Studio 2012 the platform target and build configuration is set to x86 by default. Why is this the case? For a plain WPF application (without any references to mixed mode assemblies) is there any danger using AnyCPU so my WPF executable will be JITed to x64 code on my x64 machine and to x86 on a x86 machine?
3 Answers
Why is this the case?
For most applications, building as 32bit is actually better. 64bit provides few benefits, and some significant disadvantages in most cases (much higher memory usage, more complex dependency management with multiple platforms, worse debugging experience, etc).
If, however, your application needs to be able to use large amounts of memory, then of course 64bit has advantages (and is easy to switch in VS), but most applications do not fall into this boat.
This is why the new default in VS 2012 is to use AnyCPUPrefer32Bit
instead of AnyCPU
for applications.

- 554,122
- 78
- 1,158
- 1,373
According to this bug report, it was done because of problems with Edit and Continue on x64 machines with x64 code. By changing it to x86, Edit and Continue works properly.
There should be no danger in switching it to AnyCPU. I always do this.

- 7,486
- 2
- 42
- 54
If you choose to specify a CPU, then you automatically limit your .exe to one platform or the other.
There is seldom any reason to do this, unless you absolutely have 32-bit dependencies:
In other words, there's no "performance" issue. The real issue is "compatibility". If you load any 32-bit components, and you're on a 64-bit platorm, then you must invoke WOW64. CLRTIMAGETYPE allows you to do that.
-
1As I read the question the problem is that VS picks the platform specific setting per default. – Brian Rasmussen Jun 14 '12 at 16:36
-
2Also - by picking x86, you don't limit your .exe to x86. 64bit Windows will run x86 executables under WOW64 without issue. Picking x64 does limit, but all other options do not. – Reed Copsey Jun 14 '12 at 16:41
-
+1 @Reed Copsey and an important point. Just wanted to point out (as Reed's answer pretty much makes clear) that x86 rules out ARM but not x64 based machines whereas `AnyCpuPrefer32` bit is the exact setting that describes what you mean in the preceding comment - it does not rule either ARM or x64 based machines. (I know this sentence is too long and is probably going to confuse some people more than it well help but hey...) – Ruben Bartelink Jul 14 '12 at 00:44