关于.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 版本确定的更多相关文章

  1. .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- ...

  2. c# 获取系统版本,获取net framework 版本(Environment 类)

    1.获取当前操作系统版本信息 使用Environment.OSVersion 属性 获取包含当前平台标识符和版本号的 OperatingSystem 对象. 命名空间:  System程序集:  ms ...

  3. vs版本与.net framework 版本对应

    vs2002  .net framework 1.0 vs2003 版本号:7.x  .net framework 1.1   window server 2003 vs2005 版本号:8.x  . ...

  4. 查看.Net Framework版本的方法

    乐博网最新补充(乐博网一步步教你如何最快查看本机.net framework的版本): 方法一: 第一步: 打开“我的电脑“,在地址栏输入  %systemroot%\Microsoft.NET\Fr ...

  5. Windows查看电脑上安装的.Net Framework版本的五种方法(转)

    1.查看安装文件判断Framwork版本号 打开资源管理器,比如我的电脑,再地址栏输入%systemroot%\Microsoft.NET\Framework后单击“转到”或者按回车. 在新文件夹中查 ...

  6. NET Framework 版本和依赖关系

    原文:https://docs.microsoft.com/zh-cn/dotnet/framework/migration-guide/versions-and-dependencies 每个版本的 ...

  7. 查看Windows电脑上.NET Framework版本的方法(找了好久的方法)

    照网上大多数人的方法,在路径 C:\Windows\Microsoft.NET\Framework 下可以查看到.NET Framework的版本,不过无论Win7还是Win10,显示都是这样的: 那 ...

  8. Visual Studio 2015 没显示可用的.Net Framework版本

    安装了VS 2015企业版, 然后在创建工程的时候遇到了一个问题: 当我选择Framework版本时候, 列表是空的, 如下图所示: 是生成工具出现了问题,所以尝试又安装了下 "Micros ...

  9. .NET Framework 版本和依赖关系[微软官方文档]

    .NET Framework 版本和依赖关系 微软官方文档: https://docs.microsoft.com/zh-cn/dotnet/framework/migration-guide/ver ...

  10. [转帖] .NET FrameWork 版本的确定方法

    检测电脑安装的net framework版本   https://msdn.microsoft.com/en-us/library/hh925568(v=vs.110).aspx To find .N ...

随机推荐

  1. 0基础入门学习Python(第1-2章)

    第一章:就这么愉快的开始吧 1.1获取Python Python3.7 1.2从idle启动 Python 3.7.3 (default, Mar 27 2019, 09:23:39)[Clang 1 ...

  2. Android 布局测试

    wrap_content <Button android:id="@+id/button1" android:layout_width="wrap_content& ...

  3. Toast实现源码解析

    说明 本篇文章用于介绍Android中Toast的实现原理.和简单实现一个自定义的Toast. Toast实现 一般常用Toast格式为: Toast.makeText(context,"t ...

  4. python async

    理解 python 的 async:1. 协程后面的技术也是 IO 多路复用, Nginx 和 nodejs 都充分利用了这种机制. 2. Flask 线程中为什么不能直接使用标准库 asyncio ...

  5. ORACLE ORA-1652的解决方法

    原创 Oracle 作者:wzq609 时间:2015-02-04 22:11:07 17183 0 前言:在检查数据库的alert日志,发现数据库报了ORA-1652: unable to exte ...

  6. 怎么更改當前的USERENV('LANG')返回值

    [php] SQL> ALTER SESSION SET NLS_LANGUAGE='AMERICAN'; Session altered. SQL> select USERENV('LA ...

  7. July 13th, 2018. Friday, Week 28th.

    Don't let the mistakes and disappointments of the past control and direct your future. 不要让你的未来被过去的错误 ...

  8. node.js中pm2启动应用出错

    在将公司的应用容器化时,遇到的问题. 之前,同事使用node.js 6版本运行,pm2启动js文件,一切正常. 但我一样将node.js 6版本安装,然后npm install pm2完成. 运行pm ...

  9. js字符串操作总结(必看篇)

    本文链接: https://www.jb51.net/article/97915.htm 字符方法 <!DOCTYPE html> <html lang="en" ...

  10. android appium微信等自动化的那些坑儿

    1.下载appium自动化安装环境: appium客户端 python语言支持 android studio(包含android sdk和adb) java开发环境 2.微信x5内核调试(网上有详细配 ...