为Visual Studio应用程序设置平台目标的目的是什么? [英] What is the purpose of setting the platform target for a Visual Studio application?

查看:274
本文介绍了为Visual Studio应用程序设置平台目标的目的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于任何VS项目,都可以在该项目的构建属性中设置平台目标。您可以将其设置为Any CPU,x86,x64或Itanium。我的问题是,如果将此值设置为x86,是否表示我无法在x64机器上运行该项目?如果是这样,为什么还要使用它呢?始终使用任何CPU会更好吗?

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?

推荐答案


如果我将此值设置为x86这是否意味着我不能在x64机器上运行该项目?

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

不,32位应用程序(x86)可以在64位上正常运行位Windows(x64)。 Windows的所有64位版本均包含称为Windows on Windows 64(WOW64)的32位兼容性层。实际上,这通常是您想要的 ,因为大多数应用程序都无法从64位编译中受益。

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.

但是,编译为64位(x64)确实表示您的应用程序无法在32位(x86)的计算机上运行。您可以向后(64位可以运行32位),但是不能正向(32位不能运行64位)。

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).

始终是一种选择。这样一来,该应用程序就可以在32位计算机上作为32位应用程序(x86)运行,并在64位计算机上作为64位应用程序(x64)运行。这听起来像万灵药,但要付出代价。最值得注意的是,您需要在 32位和64位环境中进行广泛的测试,而如果仅针对32位环境(包括64位的32位环境)主机),则只需测试一个构建。而且额外的工作负载几乎不值得-大多数业务应用程序无法从64位环境的额外内存空间中受益,并且可能最终因增加的64位指针开销而无法获得任何潜在收益。

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本身就是完全32位应用程序的一个很好的例子。没有64位版本,但可以在64位主机上正常运行。 此博客post 有助于阐明为何决定保留VS 32位的原因。您可能会发现推理有助于您自己做出决定。

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.

同样,尽管Microsoft Office现在以64位软件包提供,但是Microsoft仍建议大多数客户坚持使用32位版本。 64位版本存在兼容性问题,并且收益不多。

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.

这篇关于为Visual Studio应用程序设置平台目标的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆