(转)Some awareness before migrating from x86 to x64

本文转自: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

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/494815.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

大数据技术Hbase 和 Hive 详解

目录 两者的特点 各自的限制 应用场景 大数据技术Hbase 和 Hive 详解, 今天给大家介绍一下关于零基础学习大数据视频教程之HBASE 和 HIVE 是多么重要的技术,那么两者有什么区别呢 ? 下面我们一起来看一下吧。 ApacheHive 是一个构建在 hadoop 基础设…

STL中vector和list的区别

底层结构 vector的底层结构是动态顺序表,在内存中是一段连续的空间。   list的底层结构是带头节点的双向循环链表,在内存中不是一段连续的空间。 随机访问 vector支持随机访问,可以利用下标精准定位到一个元素上,访问某个元素的…

自动驾驶芯片:GPU 的现在和 ASIC 的未来

来源:乐晴智库精选▌车载芯片的发展趋势(CPU-GPU-FPGA-ASIC)过去汽车电子芯片以与传感器一一对应的电子控制单元(ECU)为主,主要分布与发动机等核心部件上。随着汽车智能化的发展,汽车传感器越来越多,传统的分布式架构逐渐落后&…

WAMP PHP开发环境

下载地址&#xff1a;php100.com 安装成功标志&#xff1a;访问localhost能够看到WampServer页面 步骤&#xff1a;(1)新建虚拟目录 php100 (2)在php100下新建test.php文件&#xff0c;用nodepad打开,输入PHP脚本 <?php echo "hello world"; ?>(3)localho…

C++多态面试题汇总

总结了一些常见的面试题&#xff0c;通过查阅资料给出了一些浅薄的解析&#xff0c;欢迎各位批评指教。 1. inliine函数可以实虚函数码&#xff1f; 不可以&#xff0c;因为inline函数没有地址&#xff0c;无法将他存放到虚函数表中。 2. 静态成员可以是虚函数吗&#xff1f…

电动汽车:新一轮三年十倍,“补贴”结束“高端”开启

来源&#xff1a;乐晴智库精选摘要&#xff1a;从最早的十城千辆新能源车示范推广&#xff0c;到2014年正式启动的二级市场新能源车大行情&#xff0c;再到当下新能源乘用车型的快速升级迭代&#xff0c;新能源汽车产业发展和投资已历经8余年。▌新能源汽车投资&#xff0c;推倒…

使用easyUI给datagrid添加pagination

author YHC 这个示例展示我们如何从服务器端加载数据和如何添加pagination 到datagrid. 查看 Demo 创建 DataGrid 从服务器端加载数据, 你应该设置url属性, 在你的服务器端你应该返回JSON格式数据.请看datagrid文档得到更多关于它的数据格式信息. <table id"tt" c…

一篇文章搞懂数据仓库:四种常见数据模型(维度模型、范式模型等)

目录 写在前面 一、为什么要进行数据仓库建模&#xff1f; 二、四种常见模型 2.1 维度模型 2.1.1 星型模型 2.1.2 雪花模型 2.1.3 星座模型 2.2 范式模型 2.3 Data Vault模型 2.4 Anchor模型 三 数据模型的评价标准 小编有话 写在前面 大数据时代&#xff0c;维度…

学习C语言可以从以下几个方面入手

学习C语言可以从以下几个方面入手&#xff1a; 了解基础知识&#xff1a;首先&#xff0c;你需要了解C语言的基本语法和规则&#xff0c;包括变量、数据类型、运算符、控制结构等。可以通过阅读相关的教材或在线教程来学习这些基础知识。动手实践&#xff1a;理论知识的学习是…

C++多态讲解以及常见面试题

多态的概念 什么是多态 ​ 多态就是在不同继承关系的类对象&#xff0c;去调用同一函数&#xff0c;产生了不同的行为。 实现多态的条件 动态绑定多态&#xff08;在运行时才知道函数的地址&#xff09;&#xff1a; 调用函数的对象是指针或引用。 被调用函数必须是虚函数&a…

王飞跃谈GE艰难的数字化转型启示:从工业智联网到工业5.0

来源&#xff1a;德先生外患&#xff1a;2018年6月26日&#xff0c;通用电气&#xff08;下文称GE&#xff09;被剔除出道琼斯工业平均指数&#xff0c;而GE自1907年即是道指成分股&#xff0c;至今坚守了111年。2017年以来&#xff0c;通用电气股价从30美元左右下跌到现在的13…

一篇文章搞懂数据仓库:常用ETL工具、方法

目录 一、什么是ETL&#xff1f; 二、ETL & ELT 三、常用的ETL工具 3.1 sqoop 3.2 DataX 3.3 Kettle 3.4 canal 3.5 StreamSets 四、ETL加载策略 4.1 增量 4.2 全量 4.3 流式 小编有话 一、什么是ETL&#xff1f; ETL&#xff0c;是英文Extract-Transform-Lo…

经典排序之 堆排序

开了个公众号「aCloudDeveloper」&#xff0c;专注技术干货分享&#xff0c;期待与你相遇。 Author: bakari Date: 2012.7.30 排序算法有很多种&#xff0c;每一种在不同的情况下都占有一席之地。关于排序算法我分“经典排序之”系列分别述之。本篇为堆排序。 堆排序是运用二叉…

操作系统之进程概念

进程概念 进程是什么&#xff1a; 表面上来说进程是程序的一个执行实例&#xff0c;或者是一个正在执行的程序等&#xff0c;从操作系统的角度来说&#xff0c;程序运行需要将代码数据加载到内存中&#xff0c;由于在操作系统中运行了很多的程序&#xff0c;操作系统就必须去管…

也谈压缩感知和贝叶斯大脑

来源&#xff1a;科学网压缩感知和人工智能都是当下很热很热的研究课题。不过许多论文数学论述高深莫测&#xff0c;加之一大堆各种千奇百怪的数学符号&#xff0c;不仅让人望而生畏&#xff0c;望而却步。笔者对希望用形象的比喻把问题大致轮廓讲清楚就好。所谓压缩感知是什么…

一篇文章搞懂数据仓库:三种事实表(设计原则,设计方法、对比)

目录 1、三种事实表概述 2、三种事实表对比 3、事实表设计 8 大原则 4、事实表设计方法 第一步&#xff1a;选择业务过程及确定事实表类型 第二步&#xff1a;声明粒度 第三步&#xff1a;确定维度 第四步&#xff1a;确定事实 事实表作为数据仓库维度建模的核心&#…

Eclipse快捷键一览

基本使用 Ctrl1 快速修复(最经典的快捷键,就不用多说了)CtrlD: 删除当前行 CtrlAlt↓ 复制当前行到下一行(复制增加)CtrlAlt↑ 复制当前行到上一行(复制增加)Alt↓ 当前行和下面一行交互位置(特别实用,可以省去先剪切,再粘贴了)Alt↑ 当前行和上面一行交互位置(同上)Alt← 前一…

深思考人工智能蝉联SMP2018多轮语义对话冠军,报告解读多轮人机对话实现过程...

人机对话技术近年来受到了学术界和产业界的广泛关注&#xff0c;其发展影响并推动着语音识别与合成、自然语言理解、对话管理以及自然语言生成等研究的进展。众多产业界巨头相继推出了人机对话技术相关产品&#xff0c;并将人机对话技术作为其公司的重点研发方向。8月3日&#…

操作系统之动态库和静态库

什么是库&#xff1f; 平时在写代码的时候会经常添加一些头文件&#xff0c;添加这些头文件其实是让编译器从一个目录下去寻找这个文件&#xff0c;这个目录就是我们常说的库。在Linux中库一般存放在user/lib目录。库就是将一些常用的函数的目标文件打包在一起&#xff0c;提供…

一篇文章搞懂数据仓库:数据仓库规范设计

目录 一、为什么要进行规范设计&#xff1f; 二、设计规范 - 指标 三、命名规范 - 表命名 3.1 常规表 3.2 中间表 3.3 临时表 3.4 维度表 四、开发规范 五、流程规范 一、为什么要进行规范设计&#xff1f; 无规矩、不方圆。规范设计是在具体开发工作之前制定的&…