I'm writing a litle app that
reads some value's from the regestry (Installation or admin user has written these values)
When I try to access this, while running the app as a standart user I get the following exception:
'System.Windows.Forms.Application.CommonAppDataRegistry' threw an exception of type 'System.UnauthorizedAccessException'
Under Admin everything works as expected.
My Test Code
RegistryKey rkey = Registry.LocalMachine;
RegistryKey test = rkey.OpenSubKey("SOFTWARE\\Microsoft\\MyApp\\1.0.0.0");
string valueFromRegestry = (string)test.GetValue("MyAppSetting"); //Works just fine...
valueFromRegestry = Application.CommonAppDataRegistry.GetValue("MyAppSetting").ToString(); // Failes with the exception below
//'System.Windows.Forms.Application.CommonAppDataRegistry' threw an exception of type 'System.UnauthorizedAccessException'
My question is why? In effect CommonAppDataRegestry points to the exect same location as the 'test' key.
Can anyone advise me what I'm doing wrong?