How to sign third party assemblies without compiling

July 17, 2012 . Coding . Comments
Tags: dotnet


Preface

So you added a third party dll to your project and now you need to sign it. Sometimes you might not have the code to modify the assembly and add your strong name key. This post will describe how you can go about signing a third party assembly without compiling the code.

Download .NET Framework 2.0

Create a Strong Name Key

First you'll need to get your existing strong name key (.snk) or create a strong name key

Use Ildasm to Sign a Third Party Assembly

I choose to use Microsoft intermediate language Disassembler (Ildasm) after having issues with Assembly Linker so go and download .Net Framework 2.0 from Microsoft if you don't already have it.

First Disassemble the ThirdParty.dll

Open a Visual Studio Command Prompt and type the following command:

D:\Common\ThirdParty>ildasm /all /out=ThirdParty.il ThirdParty.dll

This will create a file called ThirdParty.il which will be used next to sign and build.

Second Rebuild and Sign the ThirdParty.dll

Rename or backup your original third party assembly. Open a Visual Studio Command Prompt and type the following command:

D:\Common\ThirdParty>ilasm /dll /key=YourKey.snk ThirdParty.il

Finally Verify Assembly was Signed

You'll want to verify that your assembly is now signed. To do this Open an Visual Studio Command Prompt and type the following command:

sn -vf ThirdParty.dll

You should get an output similar to..

Assembly 'ThirdParty.dll' is valid

Conclusion

This is certainly happy path and only works with assemblies built using .NET libraries. If other libraries are included in the assembly you are trying to sign then you'll have to do some additional steps not listed on this post.

Comments Section

Feel free to comment on the post but keep it clean and on topic.

blog comments powered by Disqus