Visual Studio .NET “目標平台” 說明

來源:互聯網
上載者:User

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用
Just-In-Time 編譯器產生本地代碼
的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

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.