0

Hi this is my piece of code:

        RegistryKey baseKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, 
        RegistryView.Registry64).OpenSubKey("SOFTWARE");

        String[] str = baseKey.GetSubKeyNames();
        for (int i = 0; i < str.Length; i++)
            Console.WriteLine(str[i]); //Testing purpose
        RegistryKey key =
                baseKey.OpenSubKey("Werewolf");

It prints all the subkeys due to for loop and subkeys are correct including "Werewolf" key, but OpenSubKey("Werewolf") returns null and I get this exception:

System.NullReferenceException: 'Object reference not set to an instance of an object.'

Code compiled using VS2017. Ran on both x86 and x64 machines, same error.

Alireza Mohamadi
  • 511
  • 5
  • 19

0 Answers0