Signing a (3rd Party) complied .NET assembly

You may have referenced an assembly from your strongly named project and noticed an “Assembly generation failed — Referenced assembly does not have a strong name” exception. Or “Could not load file or assembly or one of its dependencies. A strongly-named assembly is required.” While working with an open-source component, I found that I was in this situation. In that case, I asked the primary developer if the assembly could be strongly named and he agree to do so. You may not have been so lucky.

  1. Start up the Visual Studio Command Prompt
  2. Create a .snk key file.
  3. Dis-assemble the assembly
  4. Re-Assemble using your strong-name key

You can use the following commands.

cd c:\workingdir\

sn -k sgKey.snk

 

You will need to replace originalAssembly below with the name of your assembly and drop a copy of it into c:\workingdir\. Use this pair of commands for a dll.

ildasm originalAssembly.dll /out:temp.il

ilasm temp.il /res:temp.res /dll /key:sgKey.snk /out:originalAssemblySN.dll

 

Use this pair of commands for an exe.

ildasm originalAssembly.exe /out:temp.il

ilasm temp.il /res:temp.res /key:sgKey.snk /out:originalAssemblySN.exe

 

That’s how you assign a strong name to (how to sign) an unsigned assembly!

Advertisements

Helpful links for new Web Application developers

Getting Started with Visual Studio

Getting Help

Training Courses

Into the Future

  • Mix 06 Presentations take a look into the future of Web and desktop development. If you want to see what the technology is evolving toward, look here.