How to Assign a Strong Name to an Unsigned 3rd-Party Assembly


Here is the scenario:  You get a .NET DLL from somewhere that provides some really cool functionality that you need for your BizTalk/SharePoint/etc application.  So you go to install the utility into the GAC, and then you realize that the DLL has not been signed.  If the assembly must be installed into the GAC, what can you do at this point to get this resolved?

The first options (and likely the best) would be to ask the developer(s) that created the assembly to give you a signed version.  If they are providing a .NET assembly for public use, it is a best practice to ensure that the assembly has a strong name.

If they will not provide you with a signed assembly, or you just can't wait for them to do that, there is another option.

Create a key pair that you will use to sign the assembly:

sn.exe -k key.snk

Disassemble the DLL using ILDASM:

ILDASM.exe SomeLibrary.dll /OUTPUT=SomeLibrary.il

This will create a "SomeLibrary.il" file that contains the IL for the assembly.  If the original assembly had embedded resources, it will also output a "SomeLibrary.res" file that contains the resources.  If that file exists, then append "/RESOURCE=SomeLibrary.res" to the command line shown below.

Reassemble the DLL using ILASM to sign the output with the key that you created:

ILASM.exe SomeLibrary.il /DLL /OUTPUT=SomeLibrary.dll /KEY=key.snk

Now you have a signed version of the assembly that you can install into the GAC.  You might want to make a backup of the original DLL, since this will overwrite that file (or you could specify a different name in OUTPUT).

I am sure that there are other ways to do this same thing.  This is just the method that I was introduced to.

Comments (6)

  1. Meysam says:

    Hi

    I am using some 3rd party components in my .NET 2 application and these components are using some DLLs that I can’t install them in GAC. I used your method and I could sign the DLLs and I successfully install the DLLs into GAC. But now the components can’t find the DLLs or can’t use the functions. There is no error message but the application simply doesn’t work.

    I’ll be gratful if you can find a way for me.

  2. Jelani Clark says:

    I just wanted to thank you, very much, for providing a very clear and PERFECT solution to my problem.  MSDN articles were useless.

    Thanks!

  3. Ravi says:

    Thanks a lot… I was working on this issue for long time.. it helped me a lot…

  4. Sagar says:

    How can we apply strong name to Protected Assembly?

    Because on first step i.e. ILDASM , it gives error as "Protected module–cannot disassemble"

  5. Scott says:

    What happens if I want to use an unsigned assembly, which has references to other unsigned assemblies?

Skip to main content