Monday, April 16, 2012

Sign unsigned .net assemblies

Many third party assemblies, particularly the open source ones, are not strongly named. If you must put an assembly like this into the GAC (e.g. for full trust access), you have to sign it so it's strongly named.

http://buffered.io/posts/net-fu-signing-an-unsigned-assembly-without-delay-signing offers the detailed steps to disassemble and reassemble an assembly:
  1. use ildasm.exe to disassemble into .il file
  2. if another assembly that this one references is just modified and signed using this method, need to modify the reference in this assembly with the public key added.
  3. rename the original assembly file .dll to something else so it's not overwritten by the next step.
  4. use ilasm.exe to re-assemble the .il file into .dll

And that's it! Now the assemly is strongly named.