6

My Visual Studio 2010 solution references a third party proprietary DLL.

When I try to compile the solution the error message reads:

Unable to emit assembly: Referenced assembly 'NameOfAssembly.DLL' does not have a strong name

Is the only solution to this issue to sign the third party DLL with my own key?

CJ7
  • 22,579
  • 65
  • 193
  • 321

3 Answers3

6

That's criminal negligence by anybody that creates assemblies used by others, given how trivial it is to give an assembly a strong name while building it. Doing it afterwards is quite painful, you have to decompile the assembly with ildasm.exe and put it back together with ilasm.exe, now using the /key option.

If you have a working relationship with the owner then send them a nastygram. If you don't then you probably should question the quality of the assembly, this is a major oversight and shows evidence that few people actually use the assembly.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • Hmm, scrap the first paragraph and send that email. – Hans Passant Mar 17 '13 at 13:11
  • 2
    @HansPassant Interestingly, Dapper isn't signed either. We are currently having to work around this with the Dapper Nuget package. We require signed assemblies on our source, which we have done by integrating the Dapper source for the time being. – Adam Houldsworth Nov 15 '13 at 15:28
  • Open source projects don't quite deserve the nastygram. Not that you have to send it very far, this is a StackExchange project and Marc Gravell is a frequent contributor :) – Hans Passant Nov 15 '13 at 15:37
  • 1
    More recently, there's also an opposite point of view, like from [this blog](https://www.pedrolamas.com/2016/03/01/still-strong-naming-your-assemblies-you-do-know-its-2016-right/) –  Aug 14 '17 at 17:01
4

Make sure you are licensed to reverse-engineer assemblies to as a strong name. I do not want you to have any legal troubles. You can strong name the assembly using the ILDASM and ILASM commands. In a Visual Studio command prompt.

Use the ILDASM to convert the assembly into MISL code. ILDASM MyThirdParty.dll /out:MyThirdParty.il

Use ILASM to compile with a strongname key. ILASM MyThirdParty.il /dll /resource=MyThirdParty.res /key=MyKey.snk

If you need to make a strong name key use the SN command. I think its the -k option. If you get a BadImage exception then you check what CLR version the assembly was compiled in. If its a CLR 2.0/3.5 then use "C:\Windows\Microsoft.NET\Framework\v2.0.50727\ILASM" instead of the 4.0 version.

user2205317
  • 109
  • 2
3

If you want strong-signed assemblies, all the references must be strong-signed. This entry describes the steps.

Community
  • 1
  • 1
Laurent Etiemble
  • 27,111
  • 5
  • 56
  • 81