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.
- Start up the Visual Studio Command Prompt
- Create a .snk key file.
- Dis-assemble the assembly
- Re-Assemble using your strong-name key
You can use the following commands.
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!