Actually, OpenSubKey only opens. If the value is not there, you have to do a CreateSubKey. Open only opens, Create creates and lets your write to read from... Go figure.
scott -----Original Message----- From: dotnet discussion [mailto:[EMAIL PROTECTED]] On Behalf Of Mattias Sjögren Sent: Monday, April 22, 2002 4:35 PM To: [EMAIL PROTECTED] Subject: Re: [DOTNET] Registry reading/writing question Peter, > Every time I run this code I get an Unhindered Exception Error >(the exact type is: System.NullReferenceException). After doing some >digging I found out that for some weird reason after the call to >OpenSubKey() myKey is still null. Why is that ? What am I doing wrong >? I don't think the leading backslash should be there, try removing it RegistryKey myKey = rootKey.OpenSubKey("Software\\MyApp", true); Mattias === Mattias Sjögren [EMAIL PROTECTED] You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com. You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.