2

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?

Pete Hilde
  • 659
  • 1
  • 10
  • 24
  • `RegistryKey` class is in `Microsoft.Win32` namespace (`mscorlib` asembly) and should be visible. You could try with some asnwers from [this question](https://stackoverflow.com/questions/37015074/visual-studio-intellisense-not-showing-some-classes) – Nino Jul 04 '17 at 08:27

3 Answers3

2

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!

Pete Hilde
  • 659
  • 1
  • 10
  • 24
1

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

Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108
Polluks
  • 525
  • 2
  • 8
  • 19
0

You need to install the Microsoft.Win32.Registry Nuget Package.

Renan Araújo
  • 3,533
  • 11
  • 39
  • 49