Asp.net core RegistryKey可以在ASP.NET Core 2.0应用程序中引用,但不能在Console.NET 2.0 Core应用程序中引用

Asp.net core RegistryKey可以在ASP.NET Core 2.0应用程序中引用,但不能在Console.NET 2.0 Core应用程序中引用,asp.net-core,.net-core,visual-studio-2017,Asp.net Core,.net Core,Visual Studio 2017,我可以在ASP.NET Core 2.0应用程序中引用RegistryKey类,但不能在Console.NET 2.0 Core应用程序中引用。为什么呢 当我尝试在RegistryKey中引用OpenBaseKey()(一个静态方法)时,出现以下编译错误 The name 'RegistryKey' does not exist in the current context 我使用的是VS2017,我的项目的目标是.NET Core 2.0(不是标准的2.0)。可能您的ASP.NET

我可以在ASP.NET Core 2.0应用程序中引用RegistryKey类,但不能在Console.NET 2.0 Core应用程序中引用。为什么呢

当我尝试在RegistryKey中引用OpenBaseKey()(一个静态方法)时,出现以下编译错误

The name 'RegistryKey' does not exist in the current context    

我使用的是VS2017,我的项目的目标是.NET Core 2.0(不是标准的2.0)。

可能您的ASP.NET Core应用程序的目标是.NET Framework,而不是.NET Core。添加所需的NuGet包以获取注册表API

它是Microsoft.Win32.Registry()。但这样一来,您就失去了可移植性,无法在Linux和MacOS上运行该应用程序