这本来是一个很小的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. hdu 2190 悼念512汶川大地震遇难同胞——重建希望小学

    题目 这道题拿到的时候拼凑了一会,感觉挺难的,然后博客说是:递推,我觉得递推其实就是找规律. 这是别人的思路:对于n米的长度,可以是由n-1长度加1而来,对于增加的1,只有三块1*1的砖一种铺法: 还 ...

  2. hdu 1116 欧拉回路+并查集

    http://acm.hdu.edu.cn/showproblem.php?pid=1116 给你一些英文单词,判断所有单词能不能连成一串,类似成语接龙的意思.但是如果有多个重复的单词时,也必须满足这 ...

  3. hdu 5012 模拟+bfs

    http://acm.hdu.edu.cn/showproblem.php?pid=5012 模拟出骰子四种反转方式,bfs,最多不会走超过6步 #include <cstdio> #in ...

  4. bootstrap collaspe

    和modal类似:也是通过data-toggle, data-target来指定: 可以把折叠插件改为手风琴,如果指定data-parent,那这个data-parent元素下的折叠插件就会像手风琴一 ...

  5. IllegalArgumentException: requirement failed: Corrupt index found

    今天突然接到客户反映线上服务器发送消息异常,登录服务器查看是kafka服务出现了问题,想重启一下服务,结果重启出现一下报错 [2017-06-30 19:29:13,708] FATAL Fatal ...

  6. ASP.NET MVC ScriptBundle 不能加载.min.js文件

    比如我用 bundles.Add(new ScriptBundle("~/bundles/easyui").Include( "~/Content/easyui/jque ...

  7. CSS 温故而知新

    如何让文字垂直居中 需要设置div的height,line-height 为一样的值,如下所示: <div class="ui-bar ui-bar-e" style=&qu ...

  8. AbpZero兼容sql2008

    笔者遇到的问题是公司服务器用的MSSQL的版本是2008,但AbpZero一些封装好的ORM语法只兼容到2012版本: 例如我遇到的问题就是AbpZero的分页就报这个错 然后我们要修改的是Entit ...

  9. .NET Core 类库中读取appsettings.json

    { "Logging": { "IncludeScopes": false, "LogLevel": { "Default&quo ...

  10. asp.net MVC把Areas区域绑定成二级域名

    先分析需求 在MVC项目中,我们如果有两个Areas.比如Test和DEMO.我们的访问地址应该是 http://localhost:8098/test http://localhost:8098/d ...