.net - 引用不属于 .NET Standard 的程序集

标签 .net visual-studio nuget .net-standard

我正在尝试了解哪些 API 是 .NET Standard 的一部分或与 .NET Standard 兼容。

Microsoft.Win32.Registry为例.它不是 .NET Standard 的一部分,因为它是特定于平台的 API(即 Microsoft Windows 平台)。因此,它没有列在 MS Docs 的“适用于”部分:

enter image description here

the .NET API Browser在 .NET Standard 中没有列出任何内容:

enter image description here

但是,如果我正在构建 .NET Standard 类库,我可以从 NuGet 中获取包:

enter image description here

我没有收到任何警告。我认为这可能与 .NET Framework 兼容性垫片有关,但我将 .NET Standard 的版本设置为低于 2.0,它仍然可以编译。

我错过了什么?

最佳答案

Microsoft.Win32.Registry 不是 .NET Standard 的一部分,但仅作为 Windows 可用 Nuget package 目标 .NET Standard 2.0(展开 Nuget 列表页面上的“依赖项”以进行验证)。这称为“平台扩展”。

您可以在 apisof.net 上查找,我们在“.NET Standard + Platform Extensions”下看到 Microsoft.Win32.Registry 支持,但在“.NET Standard”下没有看到支持,原因已经说明。

关于.net - 引用不属于 .NET Standard 的程序集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54542174/

相关文章:

continuous-integration - TeamCity 构建项目编译错误

C#如何获取当前目录路径

c# - 如何使用 C# 关联文件?

c# - Interop.xxxxx.dll 是如何生成的?

visual-studio - 在 Visual Studio 中从控制台转换为 Windows 应用程序

visual-studio - 引用、模板和 NuGet 包之间的区别?

visual-studio-2010 - 无法使用 NuGet 安装包 - 500 内部服务器错误

.net-core - 如何使用 Cake 从私有(private) VSTS 源恢复私有(private) NuGet 包

c# - 为什么 Entity Framework 实体是部分类?

c# - 为什么 IEnumerable Where 将第一个参数作为 "this"传递