0

Closed

Potential Bug: consistent UnauthorizedAccessException when Registry.SetValue() is attempted on CurrentKeys key

description

For some reason, as of the 243xx change sets, I am now consistently running into an UnauthorizedAccessException in the code when it attempts to write a new CertificateHash value to the Registry.  This occurs at the following line of code in the Utility.SetRegistryValue() function:
 
_registrySubKey.SetValue(valueName, valueData, RegistryValueKind.Binary);
 
I've been debugging it since last night but haven't been able to isolate the reason for this error.
Closed Nov 29, 2008 at 10:26 PM by MikeSL

comments

wrote Nov 29, 2008 at 7:34 PM

LOL - well it looks like I outsmarted myself once again (or is that out-dumbed?)... when I refactored the Registry-manipulation code, I neglected to check the optional parameters for the OpenSubKey() calls that I copied & pasted.
 
Turns out I didn't have the "writeable" boolean set to True, so that even in the SetRegistryValue() function I was opening the Registry as read-only.
 
D'oh.

wrote Nov 29, 2008 at 10:26 PM

Resolved with changeset 24538.

wrote Feb 12, 2013 at 8:59 PM

wrote May 15, 2013 at 1:32 AM