title: c# read registry windows 8
body: <p>I have an existing program, which demands for registry access using:</p>
  
  <pre><code>RegistryPermission permission = new RegistryPermission(RegistryPermissionAccess.AllAccess, strCheckPermission);
  permission.Demand();
  </code></pre>
  
  <p>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</p>
  
  <pre><code>Registry.LocalMachine.OpenSubKey("Software", true).CreateSubKey("myCompany")
  </code></pre>
  
  <p>Does anyone know what's going wrong in here?</p>
  
  <p>Update: a stacktrace of the exception:</p>
  
  <pre><code>System.UnauthorizedAccessException: Cannot write to the registry key.
     at Microsoft.Win32.RegistryKey.EnsureWriteable()
     at Microsoft.Win32.RegistryKey.CreateSubKey(String subkey, RegistryKeyPermissionCheck permissionCheck, RegistrySecurity registrySecurity)
  </code></pre>