The RegistryKey
type is defined in the assembly Microsoft.Win32.Registry
. You are referencing it from an older assembly that is forwarding to the newer assembly but that assembly isn't included. Add a reference to the Microsoft.Win32.Registry
assembly and your problem should go away.
Accessing registry through a dll project - error The type name 'RegistryKey' could not be found in the namespace 'Microsoft.Win32'
Jansen Barbara
6
Reputation points
Dear all,
When trying to call Registry.CurrentUser.OpenSubKey I am having The type name 'RegistryKey' could not be found in the namespace 'Microsoft.Win32'. This type has been forwarded to assembly 'Microsoft.Win32.Registry, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Consider adding a reference to that assembly.
even if including "using Microsoft.Win32;".
Same code works within program.cs
Any reason for this please and how I can resolve
Thanks
1 answer
Sort by: Most helpful
-
Michael Taylor 58,451 Reputation points
2020-11-30T15:20:31.32+00:00