title: Registry.SetValue() is not working
body: <p>I'm running my app on Windows 8.1 (64-bit), and I want to create a value in <code>HKLM\Software\Microsoft\Windows\Current Version\Run</code></p>
  
  <p>This is my code:</p>
  
  <pre><code>try
  {
      // Setting
      RegistryKey rk = Registry.LocalMachine;
      // I have to use CreateSubKey 
      // (create or open it if already exits), 
      // 'cause OpenSubKey open a subKey as read-only
      RegistryKey sk1 = rk.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",true);
      // Save the value
      sk1.SetValue("Servicio de Respaldo de Base de Datos", System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName.Replace(".vshost", ""));
  }
  catch 
  {
      MessageBox.Show("No se pudo Asignar el Inicio Automatico del servicio", "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
  }
  </code></pre>
  
  <p>This never enters the catch block, so there is no exception, but the key is never created.</p>
  
  <p>I have already tried the microsoft approach:</p>
  
  <pre><code>Microsoft.Win32.RegistryKey key;
  key = Microsoft.Win32.Registry.LocalMachine.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run");
  key.SetValue("Servicio de Respaldo de Base de Datos", System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName.Replace(".vshost", ""));
  key.Close();
  </code></pre>
  
  <p>But get the same result. Can someone can tell me why is this happening and/or how can i make it work?</p>