Visual Studio .NET "目标平台" 说明

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  

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值