[转]Visual Studio .NET "目标平台" 说明

http://blog.csdn.net/gezhaowan/article/details/6088524

The Platform Target is an often overlooked option in the build configuration for Visual Studio 2005 and 2008 projects.在Visual Studio 2005和2008项目的"生成"配置中,"目标平台"这个设置项是一个经常被忽略的选项。

For C# projects, you will find this option on the Project Properties dialog under the build tab.

对于C#项目,你会在项目属性对话框选项卡下的建设(build)方案发现它。

For VB.net projects, the setting is found on the Advanced Compiler Settings dialog which is made available via the Advanced Compile Options button on the Compile tab of the Project Properties.

对于VB.net项目,你可以在项目属性的编译选项卡的高级编译选项设置中找到他。

The list of available options are:

可用的选项列表如下:

  1. Any CPU 任何CPU
  2. x86 X86的
  3. x64 X64的
  4. Itanium 安腾

The meaning of these options is often misunderstood.

这些选项的意义往往被误解。

Based on their names, one might think that the compiler will generate code differently based upon the setting.

根据他们的名字,人们可能认为编译器将根据设置产生不同的代码。

However, the C# and VB.net compilers only generate IL code that is taken to native code by the CLR at runtime using the just-in-time compiler (unless ngen is used but that is another discussion).

然而,C#和VB.net编译器只是生成运行时才由CLR用实时编译器生成本地代码的IL代码(除非使用ngen,但那是另一个话题)。

The fact is that this setting actually does not affect the build of the assembly in any way except to set the platform status information on the assembly's CLR header.

事实是,这种设置实际上并不影响程序集的构建,只是把平台状态的信息设置到CLR头。

In other words, the Platform Target setting is meant to communicate the platform that the developer intends to be compatible with.

换句话说,平台目标的设定是为了沟通开发人员打算兼容的平台。

The default setting, Any CPU, means that the assembly will run natively on the CPU is it currently running on.

默认的设置, Any CPU(任何CPU),意味着程序集运行本地是当前正在运行CPU上。

Meaning, it will run as 64-bit on a 64-bit machine and 32-bit on a 32-bit machine.

即,它会运行64位在64位计算机和32在32位机位。

If the assembly is called from a 64-bit application, it will perform as a 64-bit assembly and so on.

如果程序集是从64位应用程序调用,它将以一个64位程序集执行

If the project is set to x86, this means the project is intended to run only as a 32-bit process.

如果项目设置为X86的,这意味着该项目的目的是只运行一个32位进程。

A 64-bit process will be unable to call into an assembly set as X86.

一个64位进程将无法调用设置为X86的程序集

Reasons to set your project as x86 include dependencies upon native DLLs that are only available in 32-bit or making native calls assuming 32-bit .

如果你的项目设置有对一个一个非托管dll的依赖,那就只有用32-bit或者作出32位本机调用本机DLL假设

Applications and assemblies marked for x86 can still run on 64-bit Windows.

标记为X86的应用程序和组件仍然可以运行在64位Windows。

However they run under WOW64 .

不过,他们运行在WOW64

Visual Studio itself runs under this emulation mode since it is a 32-bit application.

Visual Studio本身运行在模拟模式,因为它是一个32位应用程序。

Setting the project to x64 will specify that the assembly must run under 64-bit Windows.

设置为X64的项目必须运行在64位Windows。

Attempting to run the assembly on 32-bit Windows or call the assembly from a 32-bit process will result in a runtime error.

试图运行在32位Windows组件或从32位进程该调用程序集将导致运行时错误。

The final, and likely least common, setting is Itanium.

最后,可能是最不常用,设定Itanium。

This setting specifies that the assembly will only run on an Itanium processor.

此设置指定,程序集将只能运行在Itanium处理器。

The only reason to set your project for Itanium is if it has dependencies on native DLLs compiled specifically for the Itanium processor.

把项目设置为Itanium 的唯一原因是对编制为Itanium处理器的原生DLL的依赖关系。

Developers should be aware that simply marking Platform Target of an assembly as Any CPU does not guarantee that it will run on both 32-bit and 64-bit Windows.

开发者应该知道,简单把一个程序集目标平台标识Any CPU,并不能保证它可以运行在32位和64位Windows。

In fact, since Any CPU is the default setting, there are likely many applications that actually depend upon 32-bit processing but are not marked as such.

事实上,因为Any CPU是默认设置,也有可能很多应用,实际上依赖于32位进程,但却没有被标记为32-bit

These assemblies will fail under 64-bit Windows when run from a 64-bit process so it is important to perform testing for your applications before users are migrated to 64-bit.

这些组件在64位Windows上的一个64位进程中运行失败,因此在用户将被迁移到64位前为你的应用程序进行平台测试很重要的

The somewhat increasing popularity of Vista x64 will soon elevate the importance of this type of testing.

随着Vista X64的日益普及,这种类型的测试的重要性将很快有所提升

Another point to be aware of when attempting to migrate to 64-bit processing for .Net applications is the dependency upon assemblies originally built using Visual Studio 2002 and 2003.

另一点需要知道的,当要尝试迁移原来是使用Visual Studio 2002和2003组件开发的。NET程序到64位处理器时。

All assemblies targeting .Net 1.0 and 1.1 will be 32-bit only (x86) so these assemblies will need to be upgraded to newer versions, if available, or the functionality will need to be replaced in order for the process to execute as 64-bit.所有基于1.0和1.1的程序集将是32位只(X86的),所以这些组件将需要升级到可用的新版本,或者功能将需要更换,以执行该进程为64。 - 位。

Here are some excellent links on MSDN that should be required reading before migrating a complex project to 64-bit Windows:

下面是MSDN上的一些应该迁移一个复杂的项目为64位Windows之前阅读的优秀的链接:

Visual Studio 64-bit Applications

Migrating 32-bit Managed Code to 64-bit

posted @ 2011-07-26 11:54  xiaokang088  阅读(1101)  评论(0编辑  收藏  举报