Why is the default platform target for a WPF applications in Visual Studio x86 and not AnyCPU?

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?

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.


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.


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.


Need Your Help

Does Spring webservice support Java7?

glassfish-3 java-7 spring-ws xerces xalan

We are in the process of upgrading Java version from 1.6 to 1.7 for our Java EE system.