title: System.Security.Cryptography.ProtectedData.Unprotect is throwing a Invalid key error in certain circumstances
body: <p>So I am trying to utilize the Unprotect method in the System.Security.Cryptography.ProtectedData object and keep getting the exception: </p>
  
  <pre><code>cryptographicexception key not valid for use in specified state
  </code></pre>
  
  <p>I think it has to do with the DataProtectionScope (but I am not 100%).  </p>
  
  <p>This method works if I am logged in and run an service executable in DEBUG mode which means to me, it would be running under the "currentuser".   However, if I try to run the actual windows service, which runs under the LocalSystem account, it fails throwing the previous mentioned exception.</p>
  
  <p>Method:</p>
  
  <pre><code>ProtectedData.Unprotect(Byte[] byteArray, &lt;some_password_salt&gt;, DataProtectionScope.CurrentUser)
  </code></pre>
  
  <p>The DataProtectionScope Enum, only has CurrentUser or LocalMachine as your options.  I am not sure what would be the best option for resolving this.</p>
  
  <p>I have tried setting it to DataProtectionScope.LocalMachine  which according to  the MSDN article, any process running on the machine should be able to unprotect data.  But doesn't.</p>