peter
peter

Reputation: 13491

Cannot Read Some Values From Registry

In my C# app I am having trouble reading some registry keys,

RegistryKey key = Registry.LocalMachine.OpenSubKey("Software\\NameOfSoftware\\");

RegistryKey key1 = Registry.LocalMachine.OpenSubKey("Software\\NameOfSoftware\\Version1\\Databases");

RegistryKey key2 = Registry.LocalMachine.OpenSubKey("Software\\NameOfSoftware\\Version2\\Databases");

the first one there is the main key, and key1 and key2 are subkeys. I can read key1, but not key2.

I can see both keys in the registry with regedit. It is funny though if I do this,

key.GetSubKeyNames()

I get a list like this,

Version1,
SomethingElse1
SomethingElse2

Where the 'SomethingElse' keys are keys that I cannot see with regedit? Version2 is clearly missing too, but I can see it with regedit.

UPDATE: So to clarify something. The key that was working (Version1) was already there. Version2 was added because I exported the Version1 key, edited the file to replace Version1 with Version2 and imported it back in. So how can I duplicate the key without this issue?

Upvotes: 0

Views: 2493

Answers (1)

paulsm4
paulsm4

Reputation: 121599

It sounds like you might be running your C# application on Vista (or higher, e.g. Win7 or WS2008), and running into registry permissions. This article might be useful:

http://msdn.microsoft.com/en-us/magazine/cc982153.aspx

You might also be facing a related issue, "Registry Virtualization":

http://msdn.microsoft.com/en-us/library/aa965884.aspx

Upvotes: 1

Related Questions