【.NET 4.5】新增的 Prefer 32-bit target platform
这本来是一个很小的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:
- 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.
- When a 32-bit process opens a file in C:\Program Files, it actually reads/writes to C:\Program Files (x86).
- 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的更多相关文章
- CSS3新增伪类--好用的:target
问:如果让你实现下图,点击跳转后,让内容1增加一个背景颜色,你会怎么做呢? 可能很多小伙伴第一反应是用JS,给跳转绑定点击事件,然后用DOM获取到内容1,在给其添加css样式. 如果我跟你说用cs ...
- 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 ...
- 《Note --- Unreal --- MemPro (CONTINUE... ...)》
Mem pro 是一个主要集成内存泄露检测的工具,其具有自身的源码和GUI,在GUI中利用"Launch" button进行加载自己待检测的application,目前支持的平台为 ...
- Unity3D Optimizing Graphics Performance for iOS
原地址:http://blog.sina.com.cn/s/blog_72b936d801013ptr.html icense Comparisons http://unity3d.com/unity ...
- DBus接口文档
gitgit.projects.genivi.org / ipc / common-api-dbus-tools.git / blob? search: re 0544e985b6e4a6c83ddf ...
- 使用visual studio 2015调用阿里云oss .net sdk 2.2的putobject接口抛出outofmemory异常
问题描述: 使用阿里云oss .net sdk 2.2版本,使用putobject接口上传文件时,抛出outofmemory异常. 原因分析: 上传时,用于准备上传的数据缓冲区内存分配失败.与应用软件 ...
- 第一周-JAVA基本概念
1. 本周学习总结 本周学习内容: 1.JAVA的发展 2.JDK,JVM,JRE, 3.掌握JAVA的组成结构 4.掌握使用简单的编译器写javac与java命令, 关键概念之间的联系: JVM:将 ...
- sql server连接oracle并实现增删改查
需要一个软件ODAC112040Xcopy_64bit 我连接的oracle是11g r2 sqlserver 是 2016 软件下载 https://pan.baidu.com/s/1OpYmpR ...
- Python基础【day03】:字典(一)
本节内容 简述 语法 字典的使用 字典内置方法 一.简述 字典是Python中的又一种数据结构,它是通过key-value的数据类型,跟我们小时候用的新华字典差不多,通过key去访问value 二.语 ...
随机推荐
- 2018.08.20 loj#116. 有源汇有上下界最大流(模板)
传送门 貌似就是转成无源汇,然后两遍最大流搞定? 其实第二遍跑最大流是自动加上了第一次的答案. 代码: #include<bits/stdc++.h> #define N 100005 # ...
- 字典树Java实现
Trie树的原理 Trie树也称字典树,因为其效率很高,所以在在字符串查找.前缀匹配等中应用很广泛,其高效率是以空间为代价的. 利用串构建一个字典树,这个字典树保存了串的公共前缀信息,因此可以降低查询 ...
- Java中读取.properties配置文件的通用类
由于Java中读取配置文件的代码比较固定,所以可以将读取配置文件的那部分功能单独作为一个类,以后可以复用.为了能够达到复用的目的,不能由配置文件中每一个属性生成一个函数去读取,我们需要一种通用的方法读 ...
- git 删除追踪状态
当不小心添加一个不想被git记录等文件时,这个时候就算将该文件记录在了.gitignore里也是没有用的,因为那个文件已经被git记录过了,只有那些从来没有被git记录过的文件(即:自添加进项目后,从 ...
- openwrt,mjpeg流,wifi摄像头与APP联动,拍照、录像
最近公司好忙,自己主管的产品又忙着上线,好久都没更新博客了. 最近产品在做一款wifi摄像头,摄像头与手机同时连接在一个局域网内,即可实现摄像头图像在手机显示,并且拍照录像等功能 mjpeg是一张一张 ...
- C# Timer类
C# 有三种不同的Timer类 1.Threading.Timer 2.Timer.Timer 3.Forms.Timer using System; using System.Collections ...
- C++回调:利用函数指针
#include <iostream> using namespace std; /**************************************************** ...
- Argument list too long error for rm, cp, mv commands
Another option is to use find's -delete flag: find . -name "*.pdf" -delete
- 设计模式之命令模式(Command Pattern)
一.什么是命令模式? 命令模式,封装了方法调用细节,以解耦请求者与执行者,具体流程如下: 1.从请求者(客户)的角度看 请求者(客户)发出请求 -> 调用者(系统)构造命令对象封装请求 -> ...
- java 发架包
// 完整发布流程 clean compile deploy install -U -DskipTests // 把架包安装到本地,跳过测试 install -Dmaven.test.skip=tru ...