title: Unable to generate a temporary class - Cryptographic failure while signing assembly
body: <p>I have a signed class library that I want to create assemblies for via the sgen tool. However, I get an error when I try to run the following command:</p>
  
  <blockquote>
    <p>$ sgen.exe /a:testsign.dll /force /compiler:/keyfile:..\..\testsign.pfx /verbose /n<br>
    Error: Unable to generate a temporary class (result=1).<br>
    error CS1548: Cryptographic
    failure while signing assembly '[...path...]\TestSign.XmlSerializers.dll'
    -- 'Error signing assembly -
    - The parameter is incorrect. '</p>
    
    <p>If you would like more help, please type "sgen /?".</p>
  </blockquote>
  
  <p>I checked the error on <a href="http://msdn.microsoft.com/en-us/library/t21abc4c%28VS.80%29.aspx" rel="nofollow">MSDN</a> which states that</p>
  
  <blockquote>
    <p>CS1548 occurs when assembly signing fails. This is usually due to an
    invalid key file name, an invalid key file path, or a corrupt key
    file.</p>
  </blockquote>
  
  <p>However, I just created the key, the path is correct and to my knowledge Visual Studio 2010 does not create corrupt keys.</p>
  
  <p>This issue is fairly simple to reproduce.</p>
  
  <ol>
  <li>Using the code <a href="http://dotnetpad.net/ViewPaste/G1LbQutp60Kr6AMniw96bA" rel="nofollow">pasted here</a> create a new class library.</li>
  <li>Create two classes, one <code>class TestSigning</code> and one <code>class Model</code> </li>
  <li>go to Project properties > Signing and check the "Sign this assembly"</li>
  <li>create a new Strong name key file</li>
  <li>open up Visual Studio Command Prompt (2010)</li>
  <li>locate the dll and run <code>sgen /a:&lt;dllname&gt; [... as above ...]</code></li>
  </ol>
  
  <p>My guess is something with the public key for the keyfile.. But I cannot find any sources as to how I inform <code>sgen</code> of what password I have used to protect my key file.</p>
  
  <p>I am not sure how to proceed. the other threads I have looked at here on SO have the same error "header" <code>unable to generate temporary class</code> but different error details, for which none has the <code>Cryptographic failure</code> (that I have found).</p>