Assembly generation failed — Referenced assembly ‘…’ does not have a strong name

A lot of useful nuget packages can be found around. But some of them are useless when You try to reference them from an assembly which should be signed. During compilation you will get the error message:

Assembly generation failed — Referenced assembly ‘…’ does not have a strong name

How to add strong name to a third party assembly?

I used to download the original sources and recompile them with assembly signing. But last time I simply neither cannot find the original sources nor the original download location of the used version of binaries. I tried to disassemble the dll but without success: ilspy and reflector generated uncompilable code 🙁

But while googleing I found a simple 4 step solution here:

Step 1 : Run visual studio command prompt and go to directory where your DLL located.

For Example my DLL located in D:/hiren/Test.dll

Step 2 : Now create il file using below command.

D:/hiren> ildasm /all /out=Test.il Test.dll
(this command generate code library)

Step 3 : Generate new Key for sign your project.

D:/hiren> sn -k mykey.snk

Step 4 : Now sign your library using ilasm command.

D:/hiren> ilasm /dll /key=mykey.snk Test.il

Nice, eh?

Naturally You should repeat these steps each time when the referenced nugets are updated,
but this way is much easier than the download-actual-sources-and-recompile one…

This entry was tagged .

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.