title: SecurityException Requested registry access is not allowed
body: <p>I have a tool application in WPF (.NET 4.0) wich needs to access the registry and change a subkey value. But when I try to execute the app built in x86 in a Windows Server 2008 x64, I get the error "SecurityException Requested registry access is not allowed". When I execute the same application in my Windows 8 x64, the application works perfectly.</p>
  
  <p>I tried to give permission for the registry keys and even change the owner, but it's no good.</p>
  
  <p>The application is running as administrator and I set this value to the manifest file:</p>
  
  <pre><code>&lt;trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"&gt;
  &lt;security&gt;
    &lt;requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3"&gt;
      &lt;requestedExecutionLevel level="requireAdministrator" uiAccess="false" /&gt;
    &lt;/requestedPrivileges&gt;
    &lt;applicationRequestMinimum&gt;
      &lt;defaultAssemblyRequest permissionSetReference="Custom" /&gt;
      &lt;PermissionSet class="System.Security.PermissionSet" version="1" ID="Custom" SameSite="site" Unrestricted="true" /&gt;
    &lt;/applicationRequestMinimum&gt;
  &lt;/security&gt;
  </code></pre>
  
  <p></p>
  
  <p>This is the method which changes the value:</p>
  
  <pre><code>localKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
  localKey = localKey.OpenSubKey(RegistryHelper.Path64, RegistryKeyPermissionCheck.ReadWriteSubTree, RegistryRights.SetValue);
  
  if (localKey != null)
  {
      localKey.SetValue(RegistryHelper.CsKey, CryptographyHelper.Encrypt(CryptographyHelper.DefaultKey, cs.ConnectionString));
      localKey.SetValue(RegistryHelper.ProviderKey, provider);
      localKey.Close();
  }
  
  localKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32);
  localKey = localKey.OpenSubKey(RegistryHelper.Path32, RegistryKeyPermissionCheck.ReadWriteSubTree, RegistryRights.SetValue);
  
  if (localKey != null)
  {
      localKey.SetValue(RegistryHelper.CsKey, CryptographyHelper.Encrypt(CryptographyHelper.DefaultKey, cs.ConnectionString));
      localKey.SetValue(RegistryHelper.ProviderKey, provider);
      localKey.Close();
  }
  </code></pre>
  
  <p>When I change the build to AnyCPU, the application changes the value as expected on WinServer 2008 x64, but not when built as x86. In my Windows 8 x64 it works in both x86 and x64 perfectly.
  Do you guys have any clues?</p>