As the previous solutions have already told you, this is because you are running a 32-bit process on a 64-bit OS. You are being bitten by the "registry redirector" - the keys visible in
regedit
won't match the keys visible to your code.
Registry Redirector - Win32 apps | Microsoft Docs[
^]
If you can't change your application to run as a 64-bit application, you'll need to open the key with a specific
RegistryView
:
using (var hklm = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64))
using (var key = hklm.OpenSubKey(@"SOFTWARE\Microsoft\Cryptography"))
{
}
c# - OpenSubKey() returns null for a registry key that I can see in regedit.exe - Stack Overflow[
^]