Hi,
Just for sharing.
This may be a solution:
1) Load snk file with StrongNameKeyPair class
2) Assign PublicKey of Assembly with Cecil
private void Sign(string file, StrongNameKeyPair sn)
{
AssemblyDefinition ad =
AssemblyFactory.GetAssembly(file);
AssemblyNameDefinition adName = ad.Name;
adName.HashAlgorithm = AssemblyHashAlgorithm.SHA1;
adName.PublicKey = sn.PublicKey;
ad.Name.Flags &= AssemblyFlags.PublicKey;
AssemblyFactory.SaveAssembly(ad, file);
}
3) Re-sign the saved assembly with sn.exe
sn.exe -Ra AssemblyFileName StrongKeyFileName
I tested a few assemblies and it seems work.
Not sure whether it's ok for all.
Regards
Wicky
--~--~---------~--~----~------------~-------~--~----~
--
mono-cecil
-~----------~----~----~----~------~----~------~--~---