关于.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的子集,更轻量,更小

最新文章

  1. 【集合框架】JDK1.8源码分析之ArrayList(六)
  2. css实现一个写信的格式
  3. re正则表达式7_{}
  4. C. Santa Claus and Robot 思考题
  5. C#部分---利用arraylist集合做滚动抽奖;
  6. android项目中如何加载已有so库 <转>
  7. PHP 简单的加密解密算法
  8. LinGo:投资问题——线性规划
  9. JVM内存模型及垃圾收集策略解析
  10. CentOS7 安装 OpenSSL 1.0.1m 和 OpenSSH 6.8p1
  11. 学号:201621123032 《Java程序设计》第13周学习总结
  12. Android广播接收器Broadcast Receiver-android学习之旅(十二)
  13. Java学习路线图分析
  14. index.html jquery
  15. 20155332 2016-2017-2 《Java程序设计》第9周学习总结
  16. Oracle外部表详解
  17. [转]操作MySQL数据库报出:Parameter index out of range (1 > number of parameters, which is
  18. 解决Ubuntu14.04 下 E: Encountered a section with no Package: header 问题
  19. 【性能测试】:loadrunner直压MYSQL数据库的脚本开发
  20. Composer介绍

热门文章

  1. CSS3 3D变形 transform---rotateX(), rotateY(), rotateZ(), 透视(perspective)
  2. 六个office免费学习的精品教程 office自学教程让你从小白到高手
  3. 021.Docker mysql启动时执行初始化sql
  4. Linux—网络通讯管理命令
  5. markdown 编辑格式
  6. leetcode 排序问题
  7. 剑指Offer-8.跳台阶(C++/Java)
  8. 详解C++ STL set 容器
  9. 第十 构建Web内容的技术
  10. UAC简介