title: System.IO.IOException: The parameter is incorrect at Microsoft.Win32.RegistryKey.Win32Error(Int32 errorCode, String str)
body: <p>I am trying to create volatile key, running as system administrator. </p>
  
  <p>here is code that creates volatile key </p>
  
  <pre><code> internal static void SetVolitileVmRestartKey()
              {
                  Registry.LocalMachine.CreateSubKey(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MKeys\Restart", RegistryKeyPermissionCheck.Default, RegistryOptions.Volatile);
                  Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MKeys\Restart",
                      "VmRestartRequestedTime",
                      DateTime.UtcNow.ToString("o", CultureInfo.DefaultThreadCurrentCulture));
              }
  </code></pre>
  
  <p>I am getting 
  System.IO.IOException: The parameter is incorrect</p>
  
  <p>on API saw this documentation, but not sure what I need to do to resolve this.  </p>
  
  <pre><code>//   T:System.IO.IOException:
  //     The nesting level exceeds 510.-or-A system error occurred, such as deletion of
  //     the key or an attempt to create a key in the Microsoft.Win32.Registry.LocalMachine
  //     root.
   [ComVisible(false)]
          public RegistryKey CreateSubKey(string subkey, RegistryKeyPermissionCheck permissionCheck, RegistryOptions options);
  </code></pre>
  
  <p>here is stack trace </p>
  
  <pre><code>System.IO.IOException: The parameter is incorrect.
  
     at Microsoft.Win32.RegistryKey.Win32Error(Int32 errorCode, String str)
     at Microsoft.Win32.RegistryKey.CreateSubKeyInternal(String subkey, RegistryKeyPermissionCheck permissionCheck, Object registrySecurityObj, RegistryOptions registryOptions)
     at Microsoft.Win32.RegistryKey.CreateSubKey(String subkey, RegistryKeyPermissionCheck permissionCheck, RegistryOptions options)
  </code></pre>