NullReferenceException when trying to set registry permissions with C# -
i'm trying set below permissions on registry key. nullreferenceexception error when tries. being novice makes tuff. throw in permissions (which have confused me) , i'm stumped. can tell me why i'm getting this? thanks.
using system; using microsoft.win32; using system.security.accesscontrol; namespace consoleapplication7 { class program { static void main(string[] args) { registrysecurity rs = new registrysecurity(); string user = "everyone"; registrykey rk = registry.localmachine.opensubkey(@"\software\wow6432node\123test", true); rs.addaccessrule(new registryaccessrule(user, registryrights.fullcontrol | registryrights.takeownership, inheritanceflags.containerinherit, propagationflags.none, accesscontroltype.allow)); rk.setaccesscontrol(rs); } } }
this line causing error
registrykey rk = registry.localmachine.opensubkey(@"\software\wow6432node\123test", true);
place debugger here , see if has value or null. if null check path valid. if valid this
registrykey rk = registry.localmachine.opensubkey(@"\\software\\wow6432node\\123test", true);
Comments
Post a Comment