- Microsoft .net Framework 4.6.1
- Microsoft .net Framework 4.8 Targeting Pack Is Not Installed On This Machine
- Microsoft Net Framework 4.8 Mac Free
- Net 4.7
- Net Framework 4.7.2
用户可在他们的计算机上安装和运行 .NET Framework 的多个版本。Users can install and run multiple versions of the .NET Framework on their computers.当你开发或部署应用时,你可能需要知道用户的计算机上安装了哪些 .NET Framework 版本。When you develop or deploy your app, you might need to know which .NET Framework versions are installed on the user’s computer.注册表包含计算机上安装的 .NET Framework 版本列表。The registry contains a list of the .NET Framework versions installed on a computer.
.NET Framework 由两个采用不同版本的主要组件构成:The .NET Framework consists of two main components, which are versioned separately:
- 一组程序集,它们是为应用提供功能的类型与资源的集合。A set of assemblies, which are collections of types and resources that provide the functionality for your apps..NET Framework 和程序集使用相同的版本号。The .NET Framework and assemblies share the same version number.例如,.NET Framework 版本包括 4.5、4.6.1 和 4.7.2。For example, .NET Framework versions include 4.5, 4.6.1, and 4.7.2.
- 公共语言运行时 (CLR),可管理并执行应用代码。The common language runtime (CLR), which manages and executes your app's code.单个 CLR 版本通常可支持多个 .NET Framework 版本。A single CLR version typically supports multiple .NET Framework versions.例如,CLR 版本4.0.30319.xxxxx(其中 xxxxx 小于42000)支持 .NET Framework 版本 4 到 4.5.2。 For example, CLR version 4.0.30319.xxxxx where xxxxx is less than 42000, supports .NET Framework versions 4 through 4.5.2.大于或等于4.0.30319.42000 的 CLR 版本支持从 .NET Framework 4.6 开始的 .NET Framework 版本。CLR version greater than or equal to 4.0.30319.42000 supports .NET Framework versions starting with .NET Framework 4.6.
可使用社区维护的工具帮助检测安装了哪些 .NET Framework 版本:Community-maintained tools are available to help detect which .NET Framework versions are installed:
2020-3-27 注意:Windows 8、8.1 和 10 系统并不将“Microsoft.NET”作为安装的程序列出。在 Windows 8 和 8.1 中查看“程序和功能”中的“查看已安装的更新”,可能会找到相应的 KB 编号并将其删除。 重新安装 Microsoft.NET Framework: 下载并安装最新.NET 运行时. 2013-6-22 Microsoft.NET Framework是用于Windows的新托管代码编程模型。它将强大的功能与新技术结合起来,用于构建具有视觉上引人注目的用户体验的应用程序,实现跨技术边界的无缝通信,并且能支持各种业务流程。. Free downloads for building and running.NET apps on Linux, macOS, and Windows. Runtimes, SDKs, and developer packs for.NET Framework,.NET Core, and ASP.NET.
- .NET 2.0 命令行工具。A .NET 2.0 command-line tool.
- PowerShell 2.0 模块。A PowerShell 2.0 module.
有关检测已安装的每个 .NET Framework 版本更新的信息,请参阅如何:确定已安装的 .NET Framework 更新。For information about detecting the installed updates for each version of the .NET Framework, see How to: Determine which .NET Framework updates are installed.
检测 .NET Framework 4.5 及更高版本Detect .NET Framework 4.5 and later versions
计算机上安装的 .NET Framework 版本(4.5 及更高版本)列出在注册表中,位于 HKEY_LOCAL_MACHINESOFTWAREMicrosoftNET Framework SetupNDPv4Full。The version of .NET Framework (4.5 and later) installed on a machine is listed in the registry at HKEY_LOCAL_MACHINESOFTWAREMicrosoftNET Framework SetupNDPv4Full.如果缺少 Full 子项,则未安装 .NET Framework 4.5 或更高版本。If the Full subkey is missing, then .NET Framework 4.5 or above isn't installed.
备注
注册表路径中的 .NET Framework Setup 子项不以句点开头 。The NET Framework Setup subkey in the registry path does not begin with a period.
注册表中的 Release REG_DWORD 值代表已安装的 .NET Framework 版本。The Release REG_DWORD value in the registry represents the version of .NET Framework installed.
.NET Framework 版本.NET Framework version | Release 的值 Value of Release |
---|---|
.NET Framework 4.5.NET Framework 4.5 | 所有 Windows 操作系统:378389All Windows operating systems: 378389 |
.NET Framework 4.5.1.NET Framework 4.5.1 | 在 Windows 8.1 和 Windows Server 2012 R2 上:378675On Windows 8.1 and Windows Server 2012 R2: 378675 在所有其他 Windows 操作系统上:378758On all other Windows operating systems: 378758 |
.NET Framework 4.5.2.NET Framework 4.5.2 | 所有 Windows 操作系统:379893All Windows operating systems: 379893 |
.NET Framework 4.6.NET Framework 4.6 | 在 Windows 10 上:393295On Windows 10: 393295 在所有其他 Windows 操作系统上:393297On all other Windows operating systems: 393297 |
.NET Framework 4.6.1.NET Framework 4.6.1 | 在 Windows 10 11 月更新系统上:394254On Windows 10 November Update systems: 394254 在所有其他 Windows 操作系统(包括 Windows 10)上:394271On all other Windows operating systems (including Windows 10): 394271 |
.NET Framework 4.6.2.NET Framework 4.6.2 | 在 Windows 10 周年更新和 Windows Server 2016 上:394802On Windows 10 Anniversary Update and Windows Server 2016: 394802 在所有其他 Windows 操作系统(包括其他 Windows 10 操作系统)上:394806On all other Windows operating systems (including other Windows 10 operating systems): 394806 |
.NET Framework 4.7.NET Framework 4.7 | 在 Windows 10 创意者更新上:460798On Windows 10 Creators Update: 460798 在所有其他 Windows 操作系统(包括其他 Windows 10 操作系统)上:460805On all other Windows operating systems (including other Windows 10 operating systems): 460805 |
.NET Framework 4.7.1.NET Framework 4.7.1 | 在 Windows 10 Fall Creators Update 和 Windows Server 版本 1709 上:461308On Windows 10 Fall Creators Update and Windows Server, version 1709: 461308 在所有其他 Windows 操作系统(包括其他 Windows 10 操作系统)上:461310On all other Windows operating systems (including other Windows 10 operating systems): 461310 |
.NET Framework 4.7.2.NET Framework 4.7.2 | 在 Windows 10 2018 年 4 月更新和 Windows Server 版本 1803 上:461808On Windows 10 April 2018 Update and Windows Server, version 1803: 461808 在除 Windows 10 2018 年 4 月更新和 Windows Server 版本 1803 之外的所有 Windows 操作系统上:461814On all Windows operating systems other than Windows 10 April 2018 Update and Windows Server, version 1803: 461814 |
.NET Framework 4.8.NET Framework 4.8 | 在 Windows 10 2019 年 5 月更新和 Windows 10 2019 年 11 月更新上:528040On Windows 10 May 2019 Update and Windows 10 November 2019 Update: 528040 在 Windows 10 和 Windows Server 版本 1909 上:528209On Windows 10 and Windows Server, version 1909: 528209 在所有其他 Windows 操作系统(包括其他 Windows 10 操作系统)上:528049On all other Windows operating systems (including other Windows 10 operating systems): 528049 |
最低版本Minimum version
若要确定是否安装了最低版本的 .NET Framework,请使用上表中最小的 Release REG_DWORD 值来指示该版本 。To determine whether a minimum version of the .NET Framework is present, use the smallest Release REG_DWORD value for that version from the previous table.
例如,如果应用程序在 .NET Framework 4.8 或更高版本下运行,请测试 Release REG_DWORD 值是否大于或等于 528040 。For example, if your application runs under .NET Framework 4.8 or a later version, test for a Release REG_DWORD value that is greater than or equal to 528040.
.NET Framework 版本.NET Framework version | 最小值Minimum value |
---|---|
.NET Framework 4.5.NET Framework 4.5 | 378389378389 |
.NET Framework 4.5.1.NET Framework 4.5.1 | 378675378675 |
.NET Framework 4.5.2.NET Framework 4.5.2 | 379893379893 |
.NET Framework 4.6.NET Framework 4.6 | 393295393295 |
.NET Framework 4.6.1.NET Framework 4.6.1 | 394254394254 |
.NET Framework 4.6.2.NET Framework 4.6.2 | 394802394802 |
.NET Framework 4.7.NET Framework 4.7 | 460798460798 |
.NET Framework 4.7.1.NET Framework 4.7.1 | 461308461308 |
.NET Framework 4.7.2.NET Framework 4.7.2 | 461808461808 |
.NET Framework 4.8.NET Framework 4.8 | 528040528040 |
使用注册表编辑器Use Registry Editor
- 在“开始”菜单中,选择“运行”,输入“regedit”,然后选择“确定” 。From the Start menu, choose Run, enter regedit, and then select OK.必须具有管理凭据才能运行 regedit。You must have administrative credentials to run regedit.
- 在注册表编辑器中,打开以下子项: HKEY_LOCAL_MACHINESOFTWAREMicrosoftNET Framework SetupNDPv4Full。In the Registry Editor, open the following subkey: HKEY_LOCAL_MACHINESOFTWAREMicrosoftNET Framework SetupNDPv4Full.如果“Full”子项不存在,则表示尚未安装 .NET Framework 4.5 或更高版本 。If the Full subkey isn't present, then you don't have the .NET Framework 4.5 or later installed.
- 请检查名为“Release”的 REG_DWORD 条目 。Check for a REG_DWORD entry named Release.如果存在,则已安装 .NET Framework 4.5 或更高版本。If it exists, then you have .NET Framework 4.5 or later installed.其值对应于 .NET Framework 的特定版本。Its value corresponds to a particular version of the .NET Framework.以下图为例,“Release”条目的值为 528040,这是 .NET Framework 4.8 的版本密钥 。In the following figure, for example, the value of the Release entry is 528040, which is the release key for .NET Framework 4.8.
使用 PowerShell 检查最低版本Use PowerShell to check for a minimum version
使用 PowerShell 命令检查 HKEY_LOCAL_MACHINESOFTWAREMicrosoftNET Framework SetupNDPv4Full 子项“Release”条目的值 。Use PowerShell commands to check the value of the Release entry of the HKEY_LOCAL_MACHINESOFTWAREMicrosoftNET Framework SetupNDPv4Full subkey.
以下示例检查“Release”条目的值,以确定是否已安装 .NET Framework 4.6.2 或更高版本 。The following examples check the value of the Release entry to determine whether the .NET Framework 4.6.2 or later is installed.如果安装了此代码,则返回
True
,否则返回 False
。This code returns True
if it's installed and False
otherwise.使用代码查询注册表Query the registry using code
![Microsoft .net framework 4.8 targeting pack is not installed on this machine Microsoft .net framework 4.8 targeting pack is not installed on this machine](/uploads/1/2/5/6/125692380/628762617.png)
- 使用 RegistryKey.OpenBaseKey 和 RegistryKey.OpenSubKey 方法访问 Windows 注册表中的 HKEY_LOCAL_MACHINESOFTWAREMicrosoftNET Framework SetupNDPv4Full 子项。Use the RegistryKey.OpenBaseKey and RegistryKey.OpenSubKey methods to access the HKEY_LOCAL_MACHINESOFTWAREMicrosoftNET Framework SetupNDPv4Full subkey in the Windows registry.重要如果运行的应用是 32 位且在 64 位 Windows 中运行,则注册表路径与前面列出的不同。If the app you're running is 32-bit and running in 64-bit Windows, the registry paths will be different than previously listed.可在 HKEY_LOCAL_MACHINESOFTWAREWow6432Node 子项中找到 64 位注册表。The 64-bit registry is available in the HKEY_LOCAL_MACHINESOFTWAREWow6432Node subkey.例如,.NET Framework 4.5 的注册表子项为 HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftNET Framework SetupNDPv4Full 。For example, the registry subkey for .NET Framework 4.5 is HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftNET Framework SetupNDPv4Full.
- 检查 Release REG_DWORD 值以确定已安装的版本 。Check the Release REG_DWORD value to determine the installed version.为了向前兼容,可检查是否有一个值大于或等于 .NET Framework 版本表中所列的值。To be forward-compatible, check for a value greater than or equal to the value listed in the .NET Framework version table.
下例检查注册表中“Release”条目的值,以查找已安装的 .NET Framework 4.5 及更高版本 :The following example checks the value of the Release entry in the registry to find the .NET Framework 4.5 and later versions that are installed:
此示例遵循版本检查的建议做法:This example follows the recommended practice for version checking:
- 检查“Release”条目的值是否大于或等于已知版本密钥的值 。It checks whether the value of the Release entry is greater than or equal to the value of the known release keys.
- 按从最新版本到最早版本的顺序检查。It checks in order from most recent version to earliest version.
检测 .NET Framework 1.0 到 4.0Detect .NET Framework 1.0 through 4.0
.NET Framework 1.1 到 4.0 的每个版本都作为子项列出在 HKEY_LOCAL_MACHINESOFTWAREMicrosoftNET Framework SetupNDP 。Each version of .NET Framework from 1.1 to 4.0 is listed as a subkey at HKEY_LOCAL_MACHINESOFTWAREMicrosoftNET Framework SetupNDP.下表列出了每个 .NET Framework 版本的路径。The following table lists the path to each .NET Framework version.对于大多数版本,都有 Install REG_DWORD 值
1
指示已安装此版本。For most versions, there's a Install REG_DWORD value of 1
to indicate this version is installed.在这些子项中,还有一个包含版本字符串的 Version REG_SZ 值。In these subkeys, there's also a Version REG_SZ value that contains a version string.备注
注册表路径中的 .NET Framework Setup 子项不以句点开头 。The NET Framework Setup subkey in the registry path does not begin with a period.
Framework 版本Framework Version | 注册表子项Registry Subkey | “值”Value |
---|---|---|
1.01.0 | HKLMSoftwareMicrosoft.NETFrameworkPolicyv1.03705HKLMSoftwareMicrosoft.NETFrameworkPolicyv1.03705 | Install REG_SZ 等于 1 Install REG_SZ equals 1 |
1.11.1 | HKLMSoftwareMicrosoftNET Framework SetupNDPv1.1.4322HKLMSoftwareMicrosoftNET Framework SetupNDPv1.1.4322 | Install REG_DWORD 等于 1 Install REG_DWORD equals 1 |
2.02.0 | HKLMSoftwareMicrosoftNET Framework SetupNDPv2.0.50727HKLMSoftwareMicrosoftNET Framework SetupNDPv2.0.50727 | Install REG_DWORD 等于 1 Install REG_DWORD equals 1 |
3.03.0 | HKLMSoftwareMicrosoftNET Framework SetupNDPv3.0SetupHKLMSoftwareMicrosoftNET Framework SetupNDPv3.0Setup | InstallSuccess REG_DWORD 等于 1 InstallSuccess REG_DWORD equals 1 |
3.53.5 | HKLMSoftwareMicrosoftNET Framework SetupNDPv3.5HKLMSoftwareMicrosoftNET Framework SetupNDPv3.5 | Install REG_DWORD 等于 1 Install REG_DWORD equals 1 |
4.0 客户端配置文件4.0 Client Profile | HKLMSoftwareMicrosoftNET Framework SetupNDPv4ClientHKLMSoftwareMicrosoftNET Framework SetupNDPv4Client | Install REG_DWORD 等于 1 Install REG_DWORD equals 1 |
4.0 完整配置文件4.0 Full Profile | HKLMSoftwareMicrosoftNET Framework SetupNDPv4FullHKLMSoftwareMicrosoftNET Framework SetupNDPv4Full | Install REG_DWORD 等于 1 Install REG_DWORD equals 1 |
重要
如果运行的应用是 32 位且在 64 位 Windows 中运行,则注册表路径与前面列出的不同。If the app you're running is 32-bit and running in 64-bit Windows, the registry paths will be different than previously listed.可在 HKEY_LOCAL_MACHINESOFTWAREWow6432Node 子项中找到 64 位注册表。The 64-bit registry is available in the HKEY_LOCAL_MACHINESOFTWAREWow6432Node subkey.例如,.NET Framework 3.5 的注册表子项为 HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftNET Framework SetupNDPv3.5 。For example, the registry subkey for .NET Framework 3.5 is HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftNET Framework SetupNDPv3.5.
请注意,.NET Framework 1.0 子项的注册表路径与其他子项不同。Notice that the registry path to the .NET Framework 1.0 subkey is different from the others.
使用注册表编辑器(较旧的框架版本)Use Registry Editor (older framework versions)
- 在“开始”菜单中,选择“运行”,输入“regedit”,然后选择“确定” 。From the Start menu, choose Run, enter regedit, and then select OK.必须具有管理凭据才能运行 regedit。You must have administrative credentials to run regedit.
- 打开与要检查的版本匹配的子项。Open the subkey that matches the version you want to check.使用检测 .NET Framework 1.0 到 4.0部分列出的表。Use the table in the Detect .NET Framework 1.0 through 4.0 section.下图显示了 .NET Framework 3.5 的子项及其 Version 值。The following figure shows the subkey and its Version value for .NET Framework 3.5.
使用代码查询注册表(较旧的框架版本)Query the registry using code (older framework versions)
使用 Microsoft.Win32.RegistryKey 类访问 Windows 注册表中的 HKEY_LOCAL_MACHINESOFTWAREMicrosoftNET Framework SetupNDP 子项。Use the Microsoft.Win32.RegistryKey class to access the HKEY_LOCAL_MACHINESOFTWAREMicrosoftNET Framework SetupNDP subkey in the Windows registry.
Microsoft .net Framework 4.6.1
重要
如果运行的应用是 32 位且在 64 位 Windows 中运行,则注册表路径与前面列出的不同。If the app you're running is 32-bit and running in 64-bit Windows, the registry paths will be different than previously listed.可在 HKEY_LOCAL_MACHINESOFTWAREWow6432Node 子项中找到 64 位注册表。The 64-bit registry is available in the HKEY_LOCAL_MACHINESOFTWAREWow6432Node subkey.例如,.NET Framework 3.5 的注册表子项为 HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftNET Framework SetupNDPv3.5 。For example, the registry subkey for .NET Framework 3.5 is HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftNET Framework SetupNDPv3.5.
以下示例查找已安装的 .NET Framework 1-4 版本:The following example finds the .NET Framework 1 through 4 versions that are installed:
查找 CLR 版本Find CLR versions
随 .NET Framework 一起安装 .NET Framework CLR 单独进行版本控制。The .NET Framework CLR installed with .NET Framework is versioned separately.可通过两种方式检测 .NET Framework CLR 的版本:There are two ways to detect the version of the .NET Framework CLR:
- Clrver 工具The Clrver.exe tool使用 CLR 版本工具 (Clrver.exe) 确定计算机上安装了哪些版本的 CLR。Use the CLR Version tool (Clrver.exe) to determine which versions of the CLR are installed on a computer.打开 Visual Studio 开发人员命令提示并输入
clrver
。Open the Developer Command Prompt for Visual Studio and enterclrver
.示例输出:Sample output: Environment
类TheEnvironment
class重要对于 .NET Framework 4.5 及更高版本,请勿使用 Environment.Version 属性来检测 CLR 的版本。For .NET Framework 4.5 and later versions, don't use the Environment.Version property to detect the version of the CLR.而应按照检测 .NET Framework 4.5 及更高版本中所述查询注册表。Instead, query the registry as described in Detect .NET Framework 4.5 and later versions.- 查询 Environment.Version 属性以检索 Version 对象。Query the Environment.Version property to retrieve a Version object.返回的
System.Version
对象标识当前正在执行代码的运行时版本。The returnedSystem.Version
object identifies the version of the runtime that's currently executing the code.它不返回可能已安装在计算机上的程序集版本或其他运行时版本。It doesn't return assembly versions or other versions of the runtime that may have been installed on the computer.对于 .NET Framework 版本 4、4.5、4.5.1 和 4.5.2,返回的 Version 对象的字符串表示形式为 4.0.30319.xxxxx,其中 xxxxx 小于 42000。For .NET Framework versions 4, 4.5, 4.5.1, and 4.5.2, the string representation of the returned Version object has the form 4.0.30319.xxxxx, where xxxxx is less than 42000.对于 .NET Framework 4.6 及更高版本,它的格式为 4.0.30319.42000。For .NET Framework 4.6 and later versions, it has the form 4.0.30319.42000. - 获得 Version 对象后,按如下方式查询:After you have the Version object, query it as follows:
- 对于主要版本标识符(例如,4 表示版本 4.0),请使用 Version.Major 属性 。For the major release identifier (for example, 4 for version 4.0), use the Version.Major property.
- 对于次要版本标识符(例如,0 表示版本 4.0),请使用 Version.Minor 属性 For the minor release identifier (for example, 0 for version 4.0), use the Version.Minor property.
- 对于整个版本字符串(例如,4.0.30319.18010),请使用 Version.ToString 方法 。For the entire version string (for example, 4.0.30319.18010), use the Version.ToString method.此方法返回一个值,该值反映正在执行代码的运行时的版本。This method returns a single value that reflects the version of the runtime that's executing the code.它不返回可能安装在计算机上的程序集版本或其他运行时版本。It doesn't return assembly versions or other runtime versions that may be installed on the computer.
以下示例使用 Environment.Version 属性检索 CLR 版本信息:The following example uses the Environment.Version property to retrieve CLR version information:
请参阅See also
-->.NET Standard 是一套正式的 .NET API 规范,有望在所有 .NET 实现中推出。.NET Standard is a formal specification of .NET APIs that are intended to be available on all .NET implementations.推出 .NET Standard 的背后动机是要提高 .NET 生态系统中的一致性。The motivation behind .NET Standard is to establish greater uniformity in the .NET ecosystem.ECMA 335 继续为 .NET 实现行为建立统一性,尽管 ECMA 335 指定了一小组标准库,但 .NET Standard 规范包含范围更广的 .NET API。ECMA 335 continues to establish uniformity for .NET implementation behavior, and while ECMA 335 specifies a small set of standard libraries, the .NET Standard specification encompasses a broader range of .NET APIs.
.NET Standard 可实现以下重要情境:.NET Standard enables the following key scenarios:
- 为要实现的所有 .NET 实现定义一组统一的、与工作负荷无关的 BCL API。Defines uniform set of BCL APIs for all .NET implementations to implement, independent of workload.
- 使开发人员能够通过同一组 API 生成可在各种 .NET 实现中使用的可移植库。Enables developers to produce portable libraries that are usable across .NET implementations, using this same set of APIs.
- 减少甚至消除由于 .NET API 方面的原因而对共享源代码进行的条件性编译(仅适用于 OS API)。Reduces or even eliminates conditional compilation of shared source due to .NET APIs, only for OS APIs.
各种 .NET 实现以特定版本的 .NET Standard 为目标。The various .NET implementations target specific versions of .NET Standard.每个 .NET 实现版本都会公布它所支持的最高 .NET Standard 版本,这种声明意味着它也支持以前的版本。Each .NET implementation version advertises the highest .NET Standard version it supports, a statement that means it also supports previous versions.例如,.NET Framework 4.6 实现 .NET Standard 1.3。也就是说,它会公开在 .NET Standard 版本 1.0 到 1.3 中定义的所有 API。For example, .NET Framework 4.6 implements .NET Standard 1.3, which means that it exposes all APIs defined in .NET Standard versions 1.0 through 1.3.同样,.NET Framework 4.6.1 实现 .NET Standard 1.4,而 .NET Core 1.0 则实现 .NET Standard 1.6。Similarly, .NET Framework 4.6.1 implements .NET Standard 1.4, while .NET Core 1.0 implements .NET Standard 1.6.
.NET 实现支持.NET implementation support
下表列出了支持每个 .NET Standard 版本的最低平台版本。The following table lists the minimum platform versions that support each .NET Standard version.这意味着所列平台的更高版本也支持相应的 .NET Standard 版本。That means that later versions of a listed platform also support the corresponding .NET Standard version.例如,.NET Core 2.2 支持 .NET Standard 2.0 及更低版本。For example, .NET Core 2.2 supports .NET Standard 2.0 and earlier.
.NET Standard.NET Standard | 1.01.0 | 1.11.1 | 1.21.2 | 1.31.3 | 1.41.4 | 1.51.5 | 1.61.6 | 2.02.0 | 2.12.1 |
---|---|---|---|---|---|---|---|---|---|
.NET Core.NET Core | 1.01.0 | 1.01.0 | 1.01.0 | 1.01.0 | 1.01.0 | 1.01.0 | 1.01.0 | 2.02.0 | 3.03.0 |
.NET Framework 1.NET Framework 1 | 4.54.5 | 4.54.5 | 4.5.14.5.1 | 4.64.6 | 4.6.14.6.1 | 4.6.1 24.6.1 2 | 4.6.1 24.6.1 2 | 4.6.1 24.6.1 2 | N/A3N/A3 |
MonoMono | 4.64.6 | 4.64.6 | 4.64.6 | 4.64.6 | 4.64.6 | 4.64.6 | 4.64.6 | 5.45.4 | 6.46.4 |
Xamarin.iOSXamarin.iOS | 10.010.0 | 10.010.0 | 10.010.0 | 10.010.0 | 10.010.0 | 10.010.0 | 10.010.0 | 10.1410.14 | 12.1612.16 |
Xamarin.MacXamarin.Mac | 3.03.0 | 3.03.0 | 3.03.0 | 3.03.0 | 3.03.0 | 3.03.0 | 3.03.0 | 3.83.8 | 5.165.16 |
Xamarin.AndroidXamarin.Android | 7.07.0 | 7.07.0 | 7.07.0 | 7.07.0 | 7.07.0 | 7.07.0 | 7.07.0 | 8.08.0 | 10.010.0 |
通用 Windows 平台Universal Windows Platform | 10.010.0 | 10.010.0 | 10.010.0 | 10.010.0 | 10.010.0 | 10.0.1629910.0.16299 | 10.0.1629910.0.16299 | 10.0.1629910.0.16299 | 待定TBD |
UnityUnity | 2018 年 1 月2018.1 | 2018 年 1 月2018.1 | 2018 年 1 月2018.1 | 2018 年 1 月2018.1 | 2018 年 1 月2018.1 | 2018 年 1 月2018.1 | 2018 年 1 月2018.1 | 2018 年 1 月2018.1 | 待定TBD |
1 针对 .NET framework 列出的版本适用于 .NET Core 2.0 SDK 和更高版本的工具。旧版本对 .NET Standard 1.5 及更高版本使用了不同映射。如果无法升级到 Visual Studio 2017 或更高版本,可下载适用于 Visual Studio 2015 的 .NET Core 工具。1 The versions listed for .NET Framework apply to .NET Core 2.0 SDK and later versions of the tooling. Older versions used a different mapping for .NET Standard 1.5 and higher. You can download tooling for .NET Core tools for Visual Studio 2015 if you cannot upgrade to Visual Studio 2017 or a later version.
2 此处所列的版本表示 NuGet 用于确定给定 .NET Standard 库是否适用的规则。虽然 NuGet 将 .NET Framework 4.6.1 视为支持 .NET Standard 1.5 到 2.0,但使用为从 .NET Framework 4.6.1 项目构建的 .NET Standard 库存在一系列问题。对于需要使用此类库的 .NET Framework 项目,建议将项目升级到面向 .NET Framework 4.7.2 或更高版本。2 The versions listed here represent the rules that NuGet uses to determine whether a given .NET Standard library is applicable. While NuGet considers .NET Framework 4.6.1 as supporting .NET Standard 1.5 through 2.0, there are several issues with consuming .NET Standard libraries that were built for those versions from .NET Framework 4.6.1 projects. For .NET Framework projects that need to use such libraries, we recommend that you upgrade the project to target .NET Framework 4.7.2 or higher.
3 .NET Framework 不支持 .NET Standard 2.1 或更高版本。有关更多详细信息,请参阅 .NET Standard 2.1 公告。3 .NET Framework won't support .NET Standard 2.1 or later versions. For more details, see the announcement of .NET Standard 2.1.
- 列表示 .NET Standard 版本。The columns represent .NET Standard versions.每个标题单元格都是一个文档链接,其中介绍了相应版本的 .NET Standard 中新增了哪些 API。Each header cell is a link to a document that shows which APIs got added in that version of .NET Standard.
- 行表示不同的 .NET 实现。The rows represent the different .NET implementations.
- 各单元格中的版本号指示要定向到此 .NET Standard 版本所需的最低 实现版本。The version number in each cell indicates the minimum version of the implementation you'll need in order to target that .NET Standard version.
- 有关交互式表的信息,请参阅 .NET Standard 版本。For an interactive table, see .NET Standard versions.
若要查找可以定位的 .NET Standard 最高版本,请按照以下步骤操作:To find the highest version of .NET Standard that you can target, do the following steps:
- 查找要运行的 .NET 实现所在的行。Find the row that indicates the .NET implementation you want to run on.
- 在这一行中从右向左查找可以定位的 .NET Standard 版本所在的列。Find the column in that row that indicates your version starting from right to left.
- 列标题指示目标支持的 .NET Standard 版本。The column header indicates the .NET Standard version that your target supports.此外可以面向任何更低的 .NET Standard 版本。You may also target any lower .NET Standard version.更高版本的 .NET Standard 还支持实现。Higher .NET Standard versions will also support your implementation.
- 对要定位的每个平台重复执行此过程。Repeat this process for each platform you want to target.如果有多个目标平台,应选择它们都支持的最高版本。If you have more than one target platform, you should pick the smaller version among them.例如,如果要在 .NET Framework 4.5 和 .NET Core 1.0 上运行,可以使用的最高 .NET Standard 版本是 .NET Standard 1.1。For example, if you want to run on .NET Framework 4.5 and .NET Core 1.0, the highest .NET Standard version you can use is .NET Standard 1.1.
要定位哪个 .NET Standard 版本Which .NET Standard version to target
选择 .NET Standard 版本时,应权衡以下因素:When choosing a .NET Standard version, you should consider this trade-off:
- 版本越高,可使用的 API 就越多。The higher the version, the more APIs are available to you.
- 版本越低,可实现它的平台就越多。The lower the version, the more platforms implement it.
一般来说,建议尽可能定位最低版本 .NET Standard。In general, we recommend you to target the lowest version of .NET Standard possible.因此,在找到可以定位的最高版本 .NET Standard 后,请按照以下步骤操作:So, after you find the highest .NET Standard version you can target, follow these steps:
- 定位前一更低版本的 .NET Standard,然后生成项目。Target the next lower version of .NET Standard and build your project.
- 如果成功生成项目,请重复执行第 1 步。If your project builds successfully, repeat step 1.否则,重新定位到后一较高版本,这就是应该使用的版本。Otherwise, retarget to the next higher version and that's the version you should use.
但是,定位更低版本的 .NET Standard 会引入许多支持依赖项。However, targeting lower .NET Standard versions introduces a number of support dependencies.如果项目定位 .NET Standard 1.x,我们建议 还定位 .NET Standard 2.0。If your project targets .NET Standard 1.x, we recommend that you also target .NET Standard 2.0.这简化了在 .NET Standard 2.0 兼容框架上运行的库的用户的依赖项关系图,并减少了下载所需的包数。This simplifies the dependency graph for users of your library that run on .NET Standard 2.0 compatible frameworks, and it reduces the number of packages they need to download.
.NET Standard 版本控制规则.NET Standard versioning rules
版本控制规则主要有两个:There are two primary versioning rules:
- 累加性:.NET Standard 版本在逻辑上形成同心圆。也就是说,较高的版本包含较低版本的所有 API。Additive: .NET Standard versions are logically concentric circles: higher versions incorporate all APIs from previous versions.版本之间没有重大更改。There are no breaking changes between versions.
- 不可变:一旦发布,.NET Standard 版本就会冻结起来。Immutable: Once shipped, .NET Standard versions are frozen.新 API 首先会在特定的 .NET 实现(如 .NET Core)中可用。New APIs first become available in specific .NET implementations, such as .NET Core.如果 .NET Standard 评审委员会认为新 API 应可用于所有 .NET 实现,则会将它们添加到新的 .NET Standard 版本中。If the .NET Standard review board believes the new APIs should be available for all .NET implementations, they're added in a new .NET Standard version.
规范Specification
Microsoft .net Framework 4.8 Targeting Pack Is Not Installed On This Machine
.NET Standard 规范是一组标准化的 API。The .NET Standard specification is a standardized set of APIs.此规范由 .NET 实现者(具体而言,由 Microsoft(包括 .NET Framework、NET Core 和 Mono)和 Unity)进行维护。The specification is maintained by .NET implementors, specifically Microsoft (includes .NET Framework, .NET Core, and Mono) and Unity.在通过 GitHub 建立新 .NET Standard 版本的过程中,采用公众反馈流程。A public feedback process is used as part of establishing new .NET Standard versions through GitHub.
正式项目Official artifacts
正式规范是一组用于定义标准中包含的 API 的 .cs 文件。The official specification is a set of .cs files that define the APIs that are part of the standard.dotnet/standard 存储库中的 Ref 目录定义了 .NET Standard API。The ref directory in the dotnet/standard repository defines the .NET Standard APIs.
NETStandard.Library 元包(源代码)描述用于部分定义一个或多个 .NET Standard 版本的库集。The NETStandard.Library metapackage (source) describes the set of libraries that define (in part) one or more .NET Standard versions.
给定的组件(如
System.Runtime
)描述:A given component, like System.Runtime
, describes:- .NET Standard 的一部分(即其范围)。Part of .NET Standard (just its scope).
- .NET Standard 在此范围内的多个版本。Multiple versions of .NET Standard, for that scope.
标准库提供派生项目以方便读取,并实现某些开发人员方案(例如,使用编译器)。Derivative artifacts are provided to enable more convenient reading and to enable certain developer scenarios (for example, using a compiler).
- 引用程序集,以 NuGet 包的形式分发,由 NETStandard.Library 元包引用。Reference assemblies, distributed as NuGet packages and referenced by the NETStandard.Library metapackage.
包表示形式Package representation
.NET Standard 引用程序集的主要分发载体是 NuGet 包。The primary distribution vehicle for the .NET Standard reference assemblies is NuGet packages.实现会以适用于每个 .NET 实现的各种方式提供。Implementations are delivered in a variety of ways, appropriate for each .NET implementation.
NuGet 包面向一个或多个框架。NuGet packages target one or more frameworks..NET Standard 包定位“.NET Standard”框架。The .NET Standard packages target the '.NET Standard' framework.可以使用
netstandard
精简 TFM(例如 netstandard1.4
)来设定 .NET Standard 框架作为目标。You can target the .NET Standard framework using the netstandard
compact TFM (for example, netstandard1.4
).如果构建的库将在多个运行时中运行,就应将此框架作为目标。Libraries that are intended to run on multiple runtimes should target this framework.对于最广泛的 API 集,将 netstandard2.0
设定为目标,因为 .NET Standard 2.0 的可用 API 数量比 .NET Standard 1.6 的两倍还多。For the broadest set of APIs, target netstandard2.0
since the number of available APIs more than doubled between .NET Standard 1.6 and 2.0.NETStandard.Library
元包引用定义 .NET Standard 的一整套 NuGet 包。The NETStandard.Library
metapackage references the complete set of NuGet packages that define .NET Standard.要指定 netstandard
作为目标,最常见的方法是引用此元包。The most common way to target netstandard
is by referencing this metapackage.它描述并提供了对大约 40 个 .NET 库及定义 .Net Standard 的相关 API 的访问权限。It describes and provides access to the ~40 .NET libraries and associated APIs that define .NET Standard.可以引用以 netstandard
为目标的其他包来使用其他 API。You can reference additional packages that target netstandard
to get access to additional APIs.版本管理Versioning
Microsoft Net Framework 4.8 Mac Free
规范并不是单一的,而是一组版本不断线性递增的 API。The specification is not singular, but an incrementally growing and linearly versioned set of APIs.该标准的第一个版本建立了一组基准 API。The first version of the standard establishes a baseline set of APIs.后续版本将添加 API,并继承以前的版本定义的 API。Subsequent versions add APIs and inherit APIs defined by previous versions.在从标准中移除 API 方面,并没有成文的规定。There is no established provision for removing APIs from the standard.
.NET Standard 并不特定于任何一种 .NET 实现,也不与其中任一运行时的版本控制方案匹配。.NET Standard is not specific to any one .NET implementation, nor does it match the versioning scheme of any of those runtimes.
添加到任何实现(例如 .NET Framework、.NET Core 和 Mono)的 API 可被视为适合添加到规范中的候选项,尤其是本质上非常重要的 API。APIs added to any of the implementations (such as, .NET Framework, .NET Core and Mono) can be considered as candidates to add to the specification, particularly if they are thought to be fundamental in nature..NET Standard 的新版本根据 .NET 实现版本进行创建,以便可以定位 .NET Standard PCL 中的新 API。New versions of .NET Standard are created based on .NET implementation releases, enabling you to target new APIs from a .NET Standard PCL..NET Core 版本控制中更详细介绍了版本控制机制。The versioning mechanics are described in more detail in .NET Core Versioning.
.NET Standard 版本控制对于库的使用至关重要。.NET Standard versioning is important for usage.在 .NET Standard 版本既定的情况下,可以使用定位相同或更低版本的库。Given a .NET Standard version, you can use libraries that target that same or lower version.下面的做法介绍了使用 .NET Standard PCL(专用于 .NET Standard 定位)的工作流。The following approach describes the workflow for using .NET Standard PCLs, specific to .NET Standard targeting.
Net 4.7
- 选择要用于 PCL 的 .NET Standard 版本。Select a .NET Standard version to use for your PCL.
- 使用依赖相同或更低 .NET Standard 版本的库。Use libraries that depend on the same .NET Standard version or lower.
- 如果发现依赖更高 .NET Standard 版本的库,要么需要采用相同的版本,要么不要使用此库。If you find a library that depends on a higher .NET Standard version, you either need to adopt that same version or decide not to use that library.
定位 .NET StandardTargeting .NET Standard
可以结合使用 框架和 NETStandard.Library 元包来构建.NET Standard 库
netstandard
。You can build .NET Standard Libraries using a combination of the netstandard
framework and the NETStandard.Library metapackage.可以查看使用 .NET Core 工具定位 .NET Standard 的示例。You can see examples of targeting the .NET Standard with .NET Core tools..NET Framework 兼容性模式.NET Framework compatibility mode
从 .NET Standard 2.0 开始,引入了 .NET Framework 兼容性模式。Starting with .NET Standard 2.0, the .NET Framework compatibility mode was introduced.此兼容性模式允许 .NET Standard 项目引用 .NET Framework 库,就像其针对 .NET Standard 编译一样。This compatibility mode allows .NET Standard projects to reference .NET Framework libraries as if they were compiled for .NET Standard.引用 .NET Framework 库并不适用于所有项目,,例如使用 Windows Presentation Foundation (WPF) API 的库。Referencing .NET Framework libraries doesn't work for all projects, such as libraries that use Windows Presentation Foundation (WPF) APIs.
Net Framework 4.7.2
有关详细信息,请参阅 .NET Framework兼容性模式。For more information, see .NET Framework compatibility mode.
.NET Standard 库和 Visual Studio.NET Standard libraries and Visual Studio
要在 Visual Studio 中生成 .NET Standard 库,请确保 Windows 上已安装 Visual Studio 2017 版本 15.3 或更高版本,或 macOS 上已安装 Visual Studio for Mac 版本 7.1 或更高版本。In order to build .NET Standard libraries in Visual Studio, make sure you have Visual Studio 2017 version 15.3 or later installed on Windows, or Visual Studio for Mac version 7.1 or later installed on macOS.
如果项目中只需使用 .NET Standard 2.0 库,也可在 Visual Studio 2015 中执行此操作。If you only need to consume .NET Standard 2.0 libraries in your projects, you can also do that in Visual Studio 2015.但是需要安装 NuGet client 3.6 或更高版本。However, you need NuGet client 3.6 or higher installed.可从 NuGet 下载页面下载适用于 Visual Studio 2015 的 NuGet 客户端。You can download the NuGet client for Visual Studio 2015 from the NuGet downloads page.
与可移植类库的比较Comparison to Portable Class Libraries
.NET Standard 将取代可移植类库 (PCL)。.NET Standard is the replacement for Portable Class Libraries (PCL)..NET Standard 可对标准 BCL 进行组织,从而提高跨 .NET 实现的一致性,改善创建可移植库的体验。The .NET Standard improves on the experience of creating portable libraries by curating a standard BCL and establishing greater uniformity across .NET implementations as a result.定位 .NET Standard 的库是 PCL 或“基于 .NET Standard 的 PCL”。A library that targets .NET Standard is a PCL or a '.NET Standard-based PCL'.现有 PCL 是“基于配置文件的 PCL”。Existing PCLs are 'profile-based PCLs'.
虽然 .NET Standard 和 PCL 配置文件的创建目的类似,但在一些重要方面也存在差异。.NET Standard and PCL profiles were created for similar purposes but also differ in key ways.
类似之处:Similarities:
- 定义可用于二进制代码共享的 API。Define APIs that can be used for binary code sharing.
差异:Differences:
- .NET Standard 是一套组织有序的 API,而 PCL 配置文件是由现有平台的交集定义。.NET Standard is a curated set of APIs, while PCL profiles are defined by intersections of existing platforms.
- .NET Standard 的版本线性递增,而 PCL 配置文件则不是这样。.NET Standard linearly versions, while PCL profiles do not.
- PCL 配置文件代表 Microsoft 平台,而 .NET Standard 与平台无关。PCL profiles represents Microsoft platforms while the .NET Standard is platform-agnostic.
PCL 兼容性PCL compatibility
.NET Standard 与一部分 PCL 配置文件兼容。.NET Standard is compatible with a subset of PCL profiles..NET Standard 1.0、1.1 和 1.2 分别与一组 PCL 配置文件重叠。.NET Standard 1.0, 1.1 and 1.2 each overlap with a set of PCL profiles.这种重叠是由以下两个原因产生的:This overlap was created for two reasons:
- 使基于 .NET Standard 的 PCL 能够引用基于配置文件的 PCL。Enable .NET Standard-based PCLs to reference profile-based PCLs.
- 使基于配置文件的 PCL 能够打包为基于 .NET Standard 的 PCL。Enable profile-based PCLs to be packaged as .NET Standard-based PCLs.
基于配置文件的 PCL 兼容性由 Microsoft.NETCore.Portable.Compatibility NuGet 包提供。Profile-based PCL compatibility is provided by the Microsoft.NETCore.Portable.Compatibility NuGet package.引用包含基于配置文件的 PCL 的 NuGet 包时,需要这种依赖性。This dependency is required when referencing NuGet packages that contain profile-based PCLs.
与以常规方式打包的基于配置文件的 PCL 相比,打包为
netstandard
的基于配置文件的 PCL 更易于使用。Profile-based PCLs packaged as netstandard
are easier to consume than typically packaged profile-based PCLs.netstandard
打包符合现有用户的需要。netstandard
packaging is compatible with existing users.下面列出了与 .NET Standard 兼容的 PCL 配置文件集:You can see the set of PCL profiles that are compatible with the .NET Standard:
PCL 配置文件PCL Profile | .NET Standard.NET Standard | PCL 平台PCL Platforms |
---|---|---|
Profile7Profile7 | 1.11.1 | .NET Framework 4.5、Windows 8.NET Framework 4.5, Windows 8 |
Profile31Profile31 | 1.01.0 | Windows 8.1、Windows Phone Silverlight 8.1Windows 8.1, Windows Phone Silverlight 8.1 |
Profile32Profile32 | 1.21.2 | Windows 8.1、Windows Phone 8.1Windows 8.1, Windows Phone 8.1 |
Profile44Profile44 | 1.21.2 | .NET Framework 4.5.1、Windows 8.1.NET Framework 4.5.1, Windows 8.1 |
Profile49Profile49 | 1.01.0 | .NET Framework 4.5、Windows Phone Silverlight 8.NET Framework 4.5, Windows Phone Silverlight 8 |
Profile78Profile78 | 1.01.0 | .NET Framework 4.5、Windows 8、Windows Phone Silverlight 8.NET Framework 4.5, Windows 8, Windows Phone Silverlight 8 |
Profile84Profile84 | 1.01.0 | Windows Phone 8.1、Windows Phone Silverlight 8.1Windows Phone 8.1, Windows Phone Silverlight 8.1 |
Profile111Profile111 | 1.11.1 | .NET Framework 4.5、Windows 8、Windows Phone 8.1.NET Framework 4.5, Windows 8, Windows Phone 8.1 |
Profile151Profile151 | 1.21.2 | .NET Framework 4.5.1、Windows 8.1、Windows Phone 8.1.NET Framework 4.5.1, Windows 8.1, Windows Phone 8.1 |
Profile157Profile157 | 1.01.0 | Windows 8.1、Windows Phone 8.1、Windows Phone Silverlight 8.1Windows 8.1, Windows Phone 8.1, Windows Phone Silverlight 8.1 |
Profile259Profile259 | 1.01.0 | .NET Framework 4.5、Windows 8, Windows Phone 8.1、Windows Phone Silverlight 8.NET Framework 4.5, Windows 8, Windows Phone 8.1, Windows Phone Silverlight 8 |