How to Add a Strong Name to an Existing DLL That You Don’t Have the Source Files to

There are times when you need to sign a DLL with a strong name that you don’t have the source code to.  For example third party DLLs that needs to be registered to the GAC to be used with COM / COM+ objects.

This is how it is done…

  1. Generate a KeyFile
    -k keyFile.snk

  2. Get the MSIL for the assembly
    ildasm YourDLLNameHere.dll /out:YourDLLNameHere.il

  3. I like to to this just as a safety – Rename the original DLL
    ren YourDLLNameHere.dll YourDLLNameHere.dll.orig

  4. Build a new assembly from the MSIL output and your KeyFile
    ilasm YourDLLNameHere.il /dll /key= keyFile.snk

 If you’ve not got your framework and sdk paths properly mapped… In framework 2 this is where the command line utilities are installed:

  • C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ilasm.exe
  • C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\ildasm.exe
  • C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\sn.exe

One Response to “How to Add a Strong Name to an Existing DLL That You Don’t Have the Source Files to”

  1. Arkyadeep Bharadwaj says:

    my dll is datedll.dll.i want to register the dll in gac.as per your opinion i already completed 3rd process.but i am little bit confused for step 4.

    ilasm Datedll.dll.il /dll /key= keyFile.snk

    how to solve this.

Leave a Reply