c# .NET Framework 版本确定
关于.NET Framework 版本信息这里做个介绍:
1. 编译时,工程的目标的 .NET Framework 版本

同样的代码,我先选择.net 4.0,就发现有语法错误,原因是4.0版本还没提供这个API

改选 .net 4.5,语法错误消失了,因为这个API在后续的 .net已经添加了

但是运行起来,真正使用的 .NET Framework版本就不一定是目标版本了。
2. 运行时实际的Framework版本
真实运行的Framework版本跟机器安装的 Framework 版本有关,如果目标是4.5,机器上只装了 4.8。
那么由于向下兼容的原则,运行时CLR就会使用4.8去运行程序。如果机器只安装了3.5,那么CLR就会弹出一个提示框让用户去安装 4.5。
如何确定机器安装的 Framework版本呢?一般都是查看注册表:
输入 regedit 打开注册表,并找到这一项:
计算机\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP
.NET Framework 4.5之前的版本可以这样依次确认:


4.5以及之后的版本需要这样确认:

Release的值对应了 .NET Framework版本,下面是微软列举每个版本的值
| .NET Framework version | Value of the Release DWORD |
|---|---|
| .NET Framework 4.5 | All Windows operating systems: 378389 |
| .NET Framework 4.5.1 | On Windows 8.1 and Windows Server 2012 R2: 378675 On all other Windows operating systems: 378758 |
| .NET Framework 4.5.2 | All Windows operating systems: 379893 |
| .NET Framework 4.6 | On Windows 10: 393295 On all other Windows operating systems: 393297 |
| .NET Framework 4.6.1 | On Windows 10 November Update systems: 394254 On all other Windows operating systems (including Windows 10): 394271 |
| .NET Framework 4.6.2 | On Windows 10 Anniversary Update and Windows Server 2016: 394802 On all other Windows operating systems (including other Windows 10 operating systems): 394806 |
| .NET Framework 4.7 | On Windows 10 Creators Update: 460798 On all other Windows operating systems (including other Windows 10 operating systems): 460805 |
| .NET Framework 4.7.1 | On Windows 10 Fall Creators Update and Windows Server, version 1709: 461308 On all other Windows operating systems (including other Windows 10 operating systems): 461310 |
| .NET Framework 4.7.2 | On Windows 10 April 2018 Update and Windows Server, version 1803: 461808 On all Windows operating systems other than Windows 10 April 2018 Update and Windows Server, version 1803: 461814 |
| .NET Framework 4.8 | On Windows 10 May 2019 Update and Windows 10 November 2019 Update: 528040 On all other Windows operating systems (including other Windows 10 operating systems): 528049 |
3. 关于CLR版本
除了.NET Framework的assembly,还有CLR(公共语言运行时),它负责管理执行code,它的版本需要这样确认:
输入命令:clrver

CLR 2.0可以管理 .NET Framework 2.0 3.0 3.5
CLR 4.0可以管理 .NET Framework 4.0 4.5 4.5以上版本
4. 其他
.net 3.5 需要开启windows功能才能正常使用,如下图:

用code 辨识版本号
// 工程配置的目标Framework版本
Console.WriteLine(AppDomain.CurrentDomain.SetupInformation.TargetFrameworkName);
// 实际真实运行的Framework版本
Console.WriteLine(FileVersionInfo.GetVersionInfo(typeof(Uri).Assembly.Location).ProductVersion);
结果

.NET 4.0 和 .NET 4.0 Client Profile 版本的区别:
4 Client Profile 是.4的子集,更轻量,更小
c# .NET Framework 版本确定的更多相关文章
- .NET FRAMEWORK版本:4.0.30319; ASP.NET版本:4.6.118.0
https://gqqnbig.me/2015/11/23/net-framework%e7%89%88%e6%9c%ac4-0-30319-asp-net%e7%89%88%e6%9c%ac4-6- ...
- c# 获取系统版本,获取net framework 版本(Environment 类)
1.获取当前操作系统版本信息 使用Environment.OSVersion 属性 获取包含当前平台标识符和版本号的 OperatingSystem 对象. 命名空间: System程序集: ms ...
- vs版本与.net framework 版本对应
vs2002 .net framework 1.0 vs2003 版本号:7.x .net framework 1.1 window server 2003 vs2005 版本号:8.x . ...
- 查看.Net Framework版本的方法
乐博网最新补充(乐博网一步步教你如何最快查看本机.net framework的版本): 方法一: 第一步: 打开“我的电脑“,在地址栏输入 %systemroot%\Microsoft.NET\Fr ...
- Windows查看电脑上安装的.Net Framework版本的五种方法(转)
1.查看安装文件判断Framwork版本号 打开资源管理器,比如我的电脑,再地址栏输入%systemroot%\Microsoft.NET\Framework后单击“转到”或者按回车. 在新文件夹中查 ...
- NET Framework 版本和依赖关系
原文:https://docs.microsoft.com/zh-cn/dotnet/framework/migration-guide/versions-and-dependencies 每个版本的 ...
- 查看Windows电脑上.NET Framework版本的方法(找了好久的方法)
照网上大多数人的方法,在路径 C:\Windows\Microsoft.NET\Framework 下可以查看到.NET Framework的版本,不过无论Win7还是Win10,显示都是这样的: 那 ...
- Visual Studio 2015 没显示可用的.Net Framework版本
安装了VS 2015企业版, 然后在创建工程的时候遇到了一个问题: 当我选择Framework版本时候, 列表是空的, 如下图所示: 是生成工具出现了问题,所以尝试又安装了下 "Micros ...
- .NET Framework 版本和依赖关系[微软官方文档]
.NET Framework 版本和依赖关系 微软官方文档: https://docs.microsoft.com/zh-cn/dotnet/framework/migration-guide/ver ...
- [转帖] .NET FrameWork 版本的确定方法
检测电脑安装的net framework版本 https://msdn.microsoft.com/en-us/library/hh925568(v=vs.110).aspx To find .N ...
随机推荐
- 进度更新---Responsive Web Design Certification (300 hours)
进度更新---Responsive Web Design Certification (300 hours) 已经完成: basic html and html5 basic css applied ...
- JS 中 判断数据类型 typeof详解
typeof 可用来获取检测变量的数据类型 语法 typeof operand typeof(operand) 参数 operand 一个表示对象或原始值的表达式,其类型将被返回. 描述 下表总结 ...
- c++ lesson 一(命名空间输入输出)
// // main.cpp // C++lessonOne // // Created by keyan on 15/11/13. // Copyright © 2015年 keyan. All r ...
- SQL学习_WHERE 数据过滤
1.比较运算符 SQL:SELECT name, hp_max FROM heros WHERE hp_max > 6000 SQL:SELECT name, hp_max FROM heros ...
- SparkStreaming和storm的区别
这是2种不同的架构. 他们的区别是SparkStreaming的吞吐量非常高,秒级准实时处理,Storm是容错性非常高,毫秒级实时处理 解释:sparkStreaming是一次处理某个间隔的数据,比如 ...
- docker容器跨服务器的迁移的方法
docker的备份方式有export和save两种. export是当前的状态,针对的是容器,docker save 是针对镜像images. export 找出要备份容器的ID ? 1 2 3 [r ...
- 苏州市java岗位的薪资状况(1)
8月份已经正式离职,这两个月主要在做新书校对工作.9月份陆续投了几份简历,参加了两次半面试,第一次是家做办公自动化的公司,开的薪水和招聘信息严重不符,感觉实在是在浪费时间,你说你给不了那么多为什还往上 ...
- 1. Git初始
一.Git初始 1. 定义 分布式的版本控制系统,在每个使用者电脑上就有一个完整的数据仓库,没有网络依然可以使用Git.当然为了习惯及团队协作,会将本地数据同步到Git服务器或者GitHub等代码 ...
- [C13] 应用实例:图片文字识别(Application Example: Photo OCR)
应用实例:图片文字识别(Application Example: Photo OCR) 问题描述和流程图(Problem Description and Pipeline) 图像文字识别应用所作的事是 ...
- FLOPS
FLOPS FLOPS(Float Operations Per Second):每秒浮点运算量,是衡量吞吐率的一个单位,通过折算到具体的浮点操作数量上. 所谓,吞吐率——就如同水管,每秒可以流出多少 ...