title: Registry autostart causes error "The underlying provider failed on Open"
body: <p>Adding program to registry:</p>
  
  <pre><code>Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run\\", true);
  
  key.SetValue("App", AppDomain.CurrentDomain.BaseDirectory + "App.exe");
  key.Close();
  </code></pre>
  
  <p>and removing from registry:</p>
  
  <pre><code>Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
  
  key.DeleteValue("App", false);
  key.Close();
  </code></pre>
  
  <p>After starting the program needs to log in or that happens automatically, if I don't log out and close the program.</p>
  
  <p>So, problems:</p>
  
  <ol>
  <li><p>After booting the machine and starting program an error pops up with text "The underlying provider failed on Open".</p></li>
  <li><p>When I fill authorization form and click log in everything is OK.</p></li>
  </ol>
  
  <p>Maybe that happens because some Windows services like SQL Server are booting later than my program or something like that.</p>
  
  <p>What do I have to do?</p>