简体   繁体   中英

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.

My problem is that Visual Studio can't find the class although I imported the namespace using 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.

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?

I forgot to mention that I'm creating a .NET Core Application. 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!

The registry is simply not part of .NET Core. Take a look at Windows Compatibility Pack https://docs.microsoft.com/en-US/dotnet/core/porting/windows-compat-pack

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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