The problem is that it could be either part of that:
reg.GetValue("Isregistered", true)
reg
could be null - you don't show it being defined or initialised
reg.GetValue("Isregistered", true).ToString()
If
reg
is ok, then
GetValue
could be returning null.
Or, it could be in your
GetValue
method itself.
Break it up, and single step throung in the debugger:
if (reg != null)
{
object o = reg.GetValue("Isregistered", true);
currentKey = o.ToString();
}
Then you stand a chance of working out which is causing the problem.