>From the MSDN docs:
Return value for GetValue()
The data associated with name, or null if the value does not exist.

Does the value Foo Bar exist?  If not, then GetValue returns a null and
calling ToString() on the null object is the cause of your exception.

J. Keith Wedinger
http://bearcatnews.com
http://sciotofootball.com


-----Original Message-----
From: dotnet discussion [mailto:[EMAIL PROTECTED]] On Behalf Of
Peter Vertes
Sent: Thursday, May 09, 2002 4:28 PM
To: [EMAIL PROTECTED]
Subject: [DOTNET] Is this a bug in RegistryKey.GetValue() ?


Hi All,

    I'm working on something that involves manipulating the registry
remotely and I'm experiencing something strange.  Consider the
following:

Console.WriteLine(_remoteKey.GetValue("Foobar").ToString());

    Prints out the value of the Foobar key as expected.  Now if I do
this:

Console.WriteLine(_remoteKey.GetValue("Foo Bar").ToString());

    I get an exception saying: "Object reference not set to an instance
of an object".  The only thing that has changed here is that the key
name whos value I want to get contains a space.  The space shouldn't
matter because my keyname is in quotes, right ?  Is this a bug in
RegistryKey.GetValue() or am I just overlooking something ?

-Pete

---
Peter Vertes
TheBEAST.com, Inc.
404 Fifth Ave
New York, NY
10018

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.

Reply via email to