本文转自:http://www.cnblogs.com/feishunji/archive/2010/10/20/1856798.html

Let's assume we have the following three dlls:

anycpu.dll      -- compiled "any cpu"

x86.dll           -- compiled "x86"

x64.dll           -- compiled "x64"

And the following three exes:

anycpu.exe     -- compiled "any cpu"

x86.exe          -- compiled "x86"

x64.exe          -- compiled "x64"

What happens if you try to use these exes and dlls together? We have to consider two possible scenarios, running on a 32-bit machine and running on a 64-bit machine...

On a 32-bit x86 machine:

anycpu.exe -- runs as a 32-bit process, can load anycpu.dll and x86.dll, will get BadImageFormatException if it tries to load x64.dll

x86.exe -- runs as a 32-bit process, can load anycpu.dll and x86.dll, will get BadImageFormatException if it tries to load x64.dll

x64.exe -- will get BadImageFormatException when it tries to run

On a 64-bit x64 machine:

anycpu.exe -- runs as a 64-bit process, can load anycpu.dll and x64.dll, will get BadImageFormatException if it tries to load x86.dll

x86.exe -- runs as a 32-bit process, can load anycpu.dll and x86.dll, will get BadImageFormatException if it tries to load x64.dll

x64.exe -- runs as a 64-bit process, can load anycpu.dll and x64.dll, will get BadImageFormatException if it tries to load x86.dll

The Platform Target is an often overlooked option in the build configuration for Visual Studio 2005 and 2008 projects.  For C# projects, you will find this option on the Project Properties dialog under the build tab.  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.  The list of available options are:

  1. Any CPU
  2. x86
  3. 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).  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.  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.  Meaning, it will run as 64-bit on a 64-bit machine and 32-bit on a 32-bit machine.  If the assembly is called from a 64-bit application, it will perform as a 64-bit assembly and so on.

If the project is set to x86, this means the project is intended to run only as a 32-bit process.  A 64-bit process will be unable to call into an assembly set as 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 .  Applications and assemblies marked for x86 can still run on 64-bit Windows.  However they run under WOW64.  Visual Studio itself runs under this emulation mode since it is a 32-bit application.

Setting the project to x64 will specify that the assembly must run under 64-bit 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.

The final, and likely least common, setting is Itanium.  This setting specifies that the assembly will only run on an Itanium processor.  The only reason to set your project for Itanium is if it has dependencies on native DLLs compiled specifically for the Itanium processor.

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.  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.  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.  The somewhat increasing popularity of Vista x64 will soon elevate the importance of this type of testing.

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

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

Visual Studio 64-bit Applications

Migrating 32-bit Managed Code to 64-bit

Reference: http://blogs.msdn.com/b/joshwil/archive/2005/04/08/406567.aspx, http://visualstudiohacks.com/articles/visual-studio-net-platform-target-explained/

转载于:https://www.cnblogs.com/MaoBisheng/archive/2012/08/04/2622597.html

(转)Some awareness before migrating from x86 to x64相关推荐

  1. WCF 4.0 Issues with IIS 7.0 on x86 and x64 bit Machines(转载)

    If you are experienced with WCF, you know that in case of installing IIS after installing .NET frame ...

  2. x86 vs x64

    今天看到某青年的blog转贴, 那文章写得真是阎王爷打报告, 鬼话连篇. 现在网上的东西真不能看. 在这里我来写一点点关于x86和x64的东西. i686 : Intel 686 ( Pentium ...

  3. [系统底层] x86和x64下ssdt的差异

    2019独角兽企业重金招聘Python工程师标准>>> X86和x64下ssdt的差异 首先介绍一下SSDT相关的结构体 PVOID无类型指针,x86下32位,x64下64位 结构体 ...

  4. python37.dll可能与您正在运行_模块可能与您正在运行的Windows版本不兼容。检查该模块是否与regsvr32.exe的x86或x64...

    今天一个网友群里留言,他win8的系统,下载我们的软件无法正常运行,原来他的win8是64位的系统,而我们的软件是32位,而且这个软件还需要一个dll文件,没有注册就无法使用,参考下面的方法解决了 1 ...

  5. 如何检查Windows Vista , XP和2003系统是32位或64位( x86或x64 )版本

    您可能会收到一个电脑作为礼物,以及想要找出系统是否设置了一个32位或64位(微软标签,他们作为x86或x64 )为基础的作业系统,这需要特别建造的应用软件. ) . For computer or P ...

  6. msvc2017配置qt5.12.8 x86和x64库版本切换

    1. QT vs Tool安装可以直接去qt官网下载 http://download.qt.io/archive/vsaddin/ 插件版本高,但不一定好用,而且有BUG 我下载了2.5.1版本的插件 ...

  7. 【】Microsoft Dynamics CRM Server 2011 (x86 and x64) - DVD (Chinese-Simplified)

    中文(简体) 文件名:cn_microsoft_dynamics_crm_server_2011_x86_x64_dvd_649127.iso SHA1:361630F2F808F1D1827FBB0 ...

  8. 简单归纳一下32位、64位、x86、x64的区别和联系

    32位.64位.x86.x64区别和联系 一切都要从1978年说起,英特尔在这年发布了世界上第一款 x86 指令集架构的处理器「Intel 8086」. 之后这个系列的处理器名称都以数字 86 作为结 ...

  9. C++内存分布探讨,x86和x64位的细微区别

    网上在探讨C++内存分布的时候,大都是下面这种图, 外加上这么一句话:"栈区申请空间的地址(表示地址的八个十六进制数)是从大到小的,堆区申请空间地址是从小到大的." 但是,小编编译 ...

最新文章

  1. ASP.NET中随机数生成及应用
  2. 解决vue版本不匹配的问题 Vue packages version mismatch:
  3. [HOW TO]-下载android官方源码
  4. org.json使用指南
  5. delphi ---ttoolbar,ttoolbutton
  6. php链接文字变色,Linux_不断变色的文字,不断变色的文字效果,漂亮而 - phpStudy...
  7. oracle删除还原点,【赵强老师】删除表和Oracle的回收站
  8. 5 万条微信语音升入太空;阿里京东否认停止社招;雷军开怼华为 | 极客头条...
  9. Ubuntu 小白起步
  10. 计算机网络(第七版)谢希仁编著 前五章课后答案计算题详解
  11. 局域网内如何实现远程桌面控制
  12. Qt中文件读写进文本框出现乱码问题详解(gbk格式出现乱码为例)
  13. 周四007欧联杯 佛罗伦萨 VS 门兴[11]
  14. Android Studio更新后导入项目报错问题解决(Minimum supported Gradle version is ×.×.×. Current version is ×.×.× )
  15. android使用动画画心形,Android中利用画图类和线程画出闪烁的心形,送给亲爱的他(她)...
  16. 刺激战场测试fps软件,腾讯手游助手玩刺激战场怎样设置显示帧数?
  17. 工业相机基本参数以及选型参考(二)
  18. matlab 滤波器篇
  19. winsock和winsock2冲突
  20. 中国童鞋行业市场深度分析及发展研究报告

热门文章

  1. LeetCode 1713. 得到子序列的最少操作次数(最长上升子序DP nlogn)
  2. LeetCode 816. 模糊坐标
  3. 南通大学python期末考试试卷答案_南通大学2015-2016年1学期《软工》作业点评总结...
  4. oid 值 内存使用_[技术干货] zabbix监控项原型组合键值
  5. Linux命令行配置静态IP地址
  6. 2022年计算机考研学校,2022计算机考研院校推荐
  7. ipv6 访问内网_【内网渗透】—— 隐藏通信隧道技术之网络层隧道技术
  8. 2019 最全阿里天猫Java 3面真题,含面试题答案!
  9. 论文浅尝 | 神经网络是如何外推的:从前馈神经网络到图神经网络
  10. 论文征集 | 2019 Joint International Semantic Technology Conference