I have an assembly which is not strong-named. I have no source code for it.
I now need it to be signed. Is there a way to do this?
I have an assembly which is not strong-named. I have no source code for it.
I now need it to be signed. Is there a way to do this?
If the original assembly is marked for delayed signing, then you can use the sn.exe tool.
If the original assembly is not so marked, then you can disassemble it with ildasm.exe, then re-asssemble it with ilasm.exe and specify the /key argument. References: [1] [2].
Example:
> ildasm /all /out=MYASSEMBLY.il MYASSEMBLY.dll
> ilasm /dll /key=key.snk MYASSEMBLY.il
Easy way to sign 3rd party assembly is using the GUI
version of Assembly Strong Name Signer
, available here: http://brutaldev.com/post/2013/10/18/NET-Assembly-Strong-Name-Signer.
It's source code is available on Github. Uses Mono.Cecil
for the dirty work. Available also as command line
tool.
I have found the recommended ildasm
-> ilasm
round trip suggested at several places cumbersome and better to be avoided.
I don't know how Assembly Strong Name Signer
handles multi-assembly dependencies. In case it does not , the problem and it's solution is described here (published 2008): http://buffered.io/posts/net-fu-signing-an-unsigned-assembly-without-delay-signing/
Take a look at my StrongNameResigner. It can sign or resign an assembly and all assemblies that depend on it while also updating all references using a command like that:
StrongNameResigner.exe -a "c:\temp" -k "key.snk" Foo.Bar
You can sign the assembly with the help of VS command prompt.
Just type the path in VS cmd prompt where your project is physically present.
In VS cmd
<your project path>sn -k <name of your project>.snk
Then go to your project in Solution Explorer -> properties -> Signing -> check checkbox
-> Browse to the key which is created using VS cmd.