Assign a Strong Name to a Third Party Dll

Assign a Strong Name to a Third Party Dll

So here is the scenario – you get a .net dll from somewhere that contains some cool functionality you wish to use in your SharePoint application. The probem is that you cant sign your own application dll because the referenced third party dll is not signed or strongly named.

When you go to build your VS project you will get the following error – ‘Referenced assembly doesn’t have strong name’

So how can I sign/strongly name the dll I hear you ask? Well here’s how:

1.Open the Visual Studio Command Prompt – probably best to copy the dll in into the VC folder to save you having to cd or type a long path in

2.Create a key pair to sign the assembly – sn.exe –k key.snk

3.Disassemble the dll using ILDASM – ILDASM.exe Yourdll.dll /out=Yourdll.il

This will create a ‘Yourdll.il’ file containing the IL for the assembly. It will also extract the assembly so you will now have a folder with lots of files, you will also see a .res file containing the resources for the dll.

4.Reassemble the dll using ILASM to sign the output with the key created above – ILASM.exe Yourdll.il /dll /out=Yourdll2.dll /key=key.snk

5.Success! 

You should now have a signed version of the dll, you can now add this to your VS project or deploy to the GAC etc :-)!

One thought on “Assign a Strong Name to a Third Party Dll

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">