这本来是一个很小的feature并且也没有什么模糊的地方,关键是VS把这个设置成了默认值,当默认为Any CPU的时候,application会被编译成32-bit mode.

下边是我遇到的问题,在64-bit OS上,使用VS2013创建基于.net 4.5的console 工程,代码如下:

            // Software\Wow6432Node\mytest default value is 0
var x86path = @"Software\Wow6432Node\mytest";
// Software\mytest default value is 1
var x64path = @"Software\mytest";
Console.WriteLine(Registry.LocalMachine.OpenSubKey(x86path).GetValue("").ToString()); // output is 0
Console.WriteLine(Registry.LocalMachine.OpenSubKey(x64path).GetValue("").ToString()); // output is 0

Console.WriteLine(Registry.LocalMachine.OpenSubKey(x64path).GetValue("").ToString()); 希望的输出是1,最终输出0. 为什么呢?答案在MSDN中:

  • anycpu (default) compiles your assembly to run on any platform. Your application runs as a 64-bit process whenever possible and falls back to 32-bit when only that mode is available.

  • anycpu32bitpreferred compiles your assembly to run on any platform. Your application runs in 32-bit mode on systems that support both 64-bit and 32-bit applications. You can specify this option only for projects that target the .NET Framework 4.5.

  • x86 compiles your assembly to be run by the 32-bit, x86-compatible common language runtime.

http://msdn.microsoft.com/en-us/library/zekwfyz4.aspx

很显然,anycpu32bitpreferred 就是把application编译成了一个可以在ARM/X64/X86/Itanium下运行的x86 application。这一点算是一个增强,但不应该是一个默认值。

  • ------------------------
  • 64-bit and 32-bit tips:
  1. On a 64-bit Windows system, both the 32-bit and 64-bit versions of system DLLs are stored. The 64-bit DLLs are in C:\Windows\System32, and the 32-bit DLLs are in C:\Windows\SysWOW64.
  2. When a 32-bit process opens a file in C:\Program Files, it actually reads/writes to C:\Program Files (x86).
  3. There are separate views of (most of) the registry for 32-bit and 64-bit applications. You can change the 64-bit registry location and it wouldn’t be visible to 32-bit applications.

【.NET 4.5】新增的 Prefer 32-bit target platform的更多相关文章

  1. CSS3新增伪类--好用的:target

      问:如果让你实现下图,点击跳转后,让内容1增加一个背景颜色,你会怎么做呢? 可能很多小伙伴第一反应是用JS,给跳转绑定点击事件,然后用DOM获取到内容1,在给其添加css样式. 如果我跟你说用cs ...

  2. Double prefix overrides to provide 16-bit operand size in a 32/64 operating mode

    A processor supports an operating mode in which the default address size is greater than 32 bits and ...

  3. 《Note --- Unreal --- MemPro (CONTINUE... ...)》

    Mem pro 是一个主要集成内存泄露检测的工具,其具有自身的源码和GUI,在GUI中利用"Launch" button进行加载自己待检测的application,目前支持的平台为 ...

  4. Unity3D Optimizing Graphics Performance for iOS

    原地址:http://blog.sina.com.cn/s/blog_72b936d801013ptr.html icense Comparisons http://unity3d.com/unity ...

  5. DBus接口文档

    gitgit.projects.genivi.org / ipc / common-api-dbus-tools.git / blob? search: re 0544e985b6e4a6c83ddf ...

  6. 使用visual studio 2015调用阿里云oss .net sdk 2.2的putobject接口抛出outofmemory异常

    问题描述: 使用阿里云oss .net sdk 2.2版本,使用putobject接口上传文件时,抛出outofmemory异常. 原因分析: 上传时,用于准备上传的数据缓冲区内存分配失败.与应用软件 ...

  7. 第一周-JAVA基本概念

    1. 本周学习总结 本周学习内容: 1.JAVA的发展 2.JDK,JVM,JRE, 3.掌握JAVA的组成结构 4.掌握使用简单的编译器写javac与java命令, 关键概念之间的联系: JVM:将 ...

  8. sql server连接oracle并实现增删改查

    需要一个软件ODAC112040Xcopy_64bit 我连接的oracle是11g r2  sqlserver 是 2016 软件下载 https://pan.baidu.com/s/1OpYmpR ...

  9. Python基础【day03】:字典(一)

    本节内容 简述 语法 字典的使用 字典内置方法 一.简述 字典是Python中的又一种数据结构,它是通过key-value的数据类型,跟我们小时候用的新华字典差不多,通过key去访问value 二.语 ...

随机推荐

  1. 2018.09.27 hdu4507吉哥系列故事——恨7不成妻(数位dp)

    传送门 一道比较综合的数位dp. 维护三个值:[L,R][L,R][L,R] 区间中与7无关的数的数量,与7无关的数之和,与7无关的数的的平方和. 然后可以用第一个值推第二个,第一个和第二个值推第三个 ...

  2. 2018.07.17 CQOI2017 余数求和(整除分块)

    洛谷传送门 bzoj传送门 这道题要用到学习莫比乌斯反演时掌握的整除分块算法,也就是对于一个数n" role="presentation" style="pos ...

  3. Java 窗体居中 通用代码

    Toolkit kit = Toolkit.getDefaultToolkit();    // 定义工具包    Dimension screenSize = kit.getScreenSize() ...

  4. arcgis api for flex 开发入门(一)环境搭建

    http://www.cnblogs.com/wenjl520/archive/2009/06/02/1494514.html arcgis api for flex 开发入门(一)环境搭建arcgi ...

  5. 常见XML解析器

    xpp3 官网 http://www.extreme.indiana.edu/xgws/xsoap/xpp/ 简介 Xml Pull Parser (in short XPP) is a stream ...

  6. linux信号量(转载)

    本文转载自http://blog.csdn.net/qinxiongxu/article/details/7830537 信号量一.什么是信号量信号量的使用主要是用来保护共享资源,使得资源在一个时刻只 ...

  7. [label][politic-video]李锡锟的政治学视频下载链接

    李锡锟政治学 1.http://r15---sn-p5qlsn7y.googlevideo.com/videoplayback?initcwndbps=1471000&signature=09 ...

  8. BMDThread控件动态创建多线程示例

    http://www.cnblogs.com/railgunman/archive/2010/12/08/1900688.html BMDThread控件是一套相当成熟的线程控件,使用它可以让你快速的 ...

  9. Spring Boot 应用系列 4 -- Spring Boot 2 整合log4j2

    一.背景 1. log4j2传承于log4j和logback,它是目前性能最好的日志处理工具,有关它们的性能对比请看: 2. 除了性能好之外,log4j2有这么几个重要的新features: (1) ...

  10. LeetCode143:Reorder List

    题目: Given a singly linked list L: L0→L1→…→Ln-1→Ln, reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You must d ...