简体   繁体   English

即使使用Microsoft.Win32也找不到RegistryKey-Class

[英]Can't find RegistryKey-Class even when Microsoft.Win32 is used

I'm currently working on a project in which I need to work with registry keys. 我目前正在从事一个需要使用注册表项的项目。 As read in several tutorials, the namespace Microsoft.Win32 offers a class called RegistryKey to work with the registry. 如几本教程中所述,命名空间Microsoft.Win32提供了一个称为RegistryKey的类来与注册表一起使用。

My problem is that Visual Studio can't find the class although I imported the namespace using using Microsoft.Win32; 我的问题是,尽管我using Microsoft.Win32;导入了名称空间,但Visual Studio无法找到该类using Microsoft.Win32; .

Normally I only type in just a few letters and I already get a suggestion for the class I'm searching for. 通常,我只输入几个字母,我已经对正在搜索的班级提出了建议。 But now Visual Studio doesn't even suggest the class. 但是现在Visual Studio甚至不建议该类。

Did I forget anything? 我忘记了什么吗? Are there other namespaces I need to use? 我还需要使用其他名称空间吗? I'm using Visual Studio 2017 Enterprise - maybe it's because of that? 我正在使用Visual Studio 2017 Enterprise-也许是因为这个?

I forgot to mention that I'm creating a .NET Core Application. 我忘了提到我正在创建.NET Core应用程序。 As a result I had to download the required class using the NuGet Package Manager because .Net Core applications manage their references in NuGet packages! 结果,我必须使用NuGet软件包管理器下载所需的类,因为.Net Core应用程序在NuGet软件包中管理其引用!

The registry is simply not part of .NET Core. 注册表根本不是.NET Core的一部分。 Take a look at Windows Compatibility Pack https://docs.microsoft.com/en-US/dotnet/core/porting/windows-compat-pack 看看Windows兼容包https://docs.microsoft.com/zh-CN/dotnet/core/porting/windows-compat-pack

您需要安装Microsoft.Win32.Registry Nuget软件包。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM