Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the purpose of setting the platform target for a Visual Studio application?

For any VS project it is possible to set the platform target in the build properties of that project. You can set this to Any CPU, x86, x64 or Itanium. My question is, if I set this value to x86 does that mean I cannot run that project on a x64 machine? If so, why is this even used? Is it not better to just always use Any CPU?

like image 616
Sachin Kainth Avatar asked May 10 '12 12:05

Sachin Kainth


People also ask

What is Visual Studio target platform?

In Visual Studio 2015 the Target Platform Version field just sets the version of the Windows SDK to use. See this MSDN article for reference. In Visual Studio 2019, this field has been renamed Windows SDK Version.

What is a target platform?

“Target platform” is a generally used term in IT to discuss a platform of focus. A target platform can refer to the platform that something is being built for, a platform that is desirable for use, or simply a platform that a particular technology is focusing on.

What is active solution platform in Visual Studio?

The Active Solution Platform allows you to configure a specific combination of configurations for each project. The Project Platform allows you to make specific configuration settings for a project.


1 Answers

if I set this value to x86 does that mean I cannot run that project on a x64 machine?

No, 32-bit applications (x86) run just fine on 64-bit Windows (x64). All 64-bit versions of Windows include a 32-bit compatibility layer called Windows on Windows 64 (WOW64). This is usually what you want, in fact, as most applications do not benefit from being complied for 64-bit.

However, compiling for 64-bit (x64) does mean that your app will not run on a 32-bit (x86) machine. You can go backwards (64-bit can run 32-bit), but you cannot go forwards (32-bit cannot run 64-bit).

Compiling for Any CPU is always an option, as you point out. That will allow the application to run as a 32-bit application (x86) on a 32-bit machine, and as a 64-bit application (x64) on a 64-bit machine. This sounds like a panacea, but there are costs. Most notably, you'll need to test your application extensively in both 32-bit and 64-bit environments, whereas if you only target 32-bit environments (including 32-bit environments on a 64-bit host), you only have to test one build. And the additional workload is rarely worth it—most business applications do not benefit from the extra memory space of a 64-bit environment, and probably end up defeating any potential gains by the increased overhead of 64-bit pointers.

Visual Studio itself is a good example of an application that is fully 32-bit. There is no 64-bit version, yet it runs fine on a 64-bit host. This blog post helps to shed some light on why the decision has been made to keep VS 32-bit. You might find the reasoning helpful in making the decision yourself.

Likewise, although Microsoft Office is now available in a 64-bit package, Microsoft is still recommending that most customers stick with the 32-bit version. There are compatibility problems with the 64-bit version, and there just isn't much benefit.

like image 193
Cody Gray Avatar answered Sep 19 '22 02:09

Cody Gray