I have an existing program, which demands for registry access using:
RegistryPermission permission = new RegistryPermission(RegistryPermissionAccess.AllAccess, strCheckPermission);
permission.Demand();
This works fine for Windows XP till Windows 7, and Windows Server 2003 and 2008. However, when I run this on Windows 8, when I demand this permission set, I still can't create a SubKey
Registry.LocalMachine.OpenSubKey("Software", true).CreateSubKey("myCompany")
Does anyone know what's going wrong in here?
Update: a stacktrace of the exception:
System.UnauthorizedAccessException: Cannot write to the registry key.
at Microsoft.Win32.RegistryKey.EnsureWriteable()
at Microsoft.Win32.RegistryKey.CreateSubKey(String subkey, RegistryKeyPermissionCheck permissionCheck, RegistrySecurity registrySecurity)