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:
$ sgen.exe /a:testsign.dll /force /compiler:/keyfile:..\..\testsign.pfx /verbose /n
Error: Unable to generate a temporary class (result=1).
error CS1548: Cryptographic failure while signing assembly '[...path...]\TestSign.XmlSerializers.dll' -- 'Error signing assembly - - The parameter is incorrect. 'If you would like more help, please type "sgen /?".
I checked the error on MSDN which states that
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.
However, I just created the key, the path is correct and to my knowledge Visual Studio 2010 does not create corrupt keys.
This issue is fairly simple to reproduce.
class TestSigning
and one class Model
sgen /a:<dllname> [... as above ...]
My guess is something with the public key for the keyfile.. But I cannot find any sources as to how I inform sgen
of what password I have used to protect my key file.
I am not sure how to proceed. the other threads I have looked at here on SO have the same error "header" unable to generate temporary class
but different error details, for which none has the Cryptographic failure
(that I have found).
Following the instructions in this thread solved this issue. Although it wasn't done manually with the sgen
tool, it was done via Visual Studio.
That is, the above example is changed to:
Paste the following snippet somewhere
<PropertyGroup>
<SGenUseProxyTypes>false</SGenUseProxyTypes>
<SGenPlatformTarget>$(Platform)</SGenPlatformTarget>
</PropertyGroup>
Reload and build the project.