Hi, im new to c# and new to this forum.

Win 7 64bit
.net 3.5 (using vs2008)

I found this code online to get the 'UninstallString' from a specific subkey within the registry. I am trying to debug the code but im getting the 'Object reference not set to an instance of an object.' error.

I broke down the code in order to find where it was giving me the error and its at the point where the code posted below has *** ***.

Im not really sure how to fix this. I previously put a try and catch but it would still break the program. Any help on this would be appreciated.

Code Below:

String AppName = "Abode AIR";

RegistryKey ReadReg = Registry.LocalMachine
.OpenSubKey("SOFTWARE")
.OpenSubKey("Microsoft")
.OpenSubKey("Windows")
.OpenSubKey("CurrentVersion")
.OpenSubKey("Installer")
.OpenSubKey("UserData")
.OpenSubKey("S-1-5-18")
.OpenSubKey("Products");
String[] SubNames = ReadReg.GetSubKeyNames();
Console.ReadLine(); //Dont mind this line
for (int i = 0; i < SubNames.Length; i++)
{
RegistryKey temp = ReadReg.OpenSubKey(SubNames[i])
.OpenSubKey("InstallProperties");
***if (temp.GetValue("DisplayName").ToString() == AppName)***
{
Console.WriteLine("Found it");
}
}


Thanks for your support