13
votes

This is a classic problem, which has numerous solutions described. However, none of them seem to work for me.

I am using the Report.NET library in a SharePoint solution. Adding the Reports.dll as a reference and compiling results in the error message "Assembly generation failed - Referenced assembly 'Reports' does not have a strong name." My project, however, has a key.snk linked in the project properties. So I try to disassemble, sign and reassemble the dll with this key file, as described elsewhere:

C:\Users\Administrator\Documents\Visual Studio 2010\Projects\MyProj
\dll>ildasm Reports.dll /out:Reports.il

C:\Users\Administrator\Documents\Visual Studio 2010\Projects\MyProj
\dll>ilasm Reports.il /dll /resource=Reports.res /key=..\key.snk

<output removed for brevity>

Class 95
Class 96
Method Implementations (total): 1
Resolving local member refs: 0 -> 0 defs, 0 refs, 0 unresolved
Writing PE file
Signing file with strong name
Operation completed successfully

I end up with a new Reports.dll timestamped to now. Adding this as a reference to my project and building, though, gives the same error message as before. The properties of the "Reports" reference displays "Strong Name: False".

Not to be discouraged by a bit of trouble, I attempt to re-sign the assembly using the strong naming utility:

C:\Users\Administrator\Documents\Visual Studio 2010\Projects\MyProj
\dll>sn -R Reports.dll ..\key.snk

Microsoft (R) .NET Framework Strong Name Utility  Version 4.0.30319.1
Copyright (c) Microsoft Corporation.  All rights reserved.

Assembly 'Reports.dll' successfully re-signed

It might be worth noting that running the SN utility fails with the error message "Reports.dll does not represent a strongly named assembly" when running it before the disassemble/sign/reassemble process.

However, when running it after disassembly/signing/reassembly, I still get the original error message when re-adding it to Visual Studio.

2

2 Answers

22
votes

I just solved this problem in vs 2010 using this:

Project Properties -> Signing -> uncheck Sign the assembly checkbox
3
votes

I would suggest that if, after you have unambiguously signed the Reports.dll correctly from the command line, VS still says that that dll is unsigned; then it must be referencing the wrong file.

If you want to be really paranoid and double-check the strong-naming after signing, load Reports.dll into ildasm (you have to double-click the manifest node in the tree and scroll down to find the .publickey section). Or for ease just open it in ILSpy.

After signing reports.dll; open your referencing project's proj file as an XML document (if you have the VS PowerCommands you can right-click and 'Edit Project File'; otherwise you can unload the project and then open it in VS using the 'Open With' command from the Open File dialog) and verify that the reference to the dll is indeed the correct path. If it's not, correct it and reload the project.