程序集生成失败 - 引用程序集没有强名称.为什么其他解决方案无效?

Gei*_*tad 12 .net sharepoint code-signing visual-studio-2010

这是一个经典问题,其中描述了许多解决方案.但是,它们似乎都不适合我.

我在SharePoint解决方案中使用Report.NET库.添加Reports.dll作为参考并在错误消息中编译结果"程序集生成失败 - 参考程序集'报告'没有强名称." 但是,我的项目在项目属性中链接了一个key.snk.所以我尝试用这个密钥文件反汇编,签名和重新组装dll,如别处所述:

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
Run Code Online (Sandbox Code Playgroud)

我最终得到了一个新的Reports.dll时间戳.但是,将此作为对项目和构建的引用添加,会提供与以前相同的错误消息."Reports"引用的属性显示"强名称:False".

不要因为有点麻烦而气馁,我尝试使用强命名实用程序重新签名程序集:

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
Run Code Online (Sandbox Code Playgroud)

值得注意的是,在反汇编/签名/重组过程之前运行SN实用程序时,运行SN实用程序失败并显示错误消息"Reports.dll不代表强名称程序集" .

但是,在反汇编/签名/重组后运行它时,我仍然会在重新添加到Visual Studio时收到原始错误消息.

小智 20

我刚用vs 2010解决了这个问题:

Project Properties -> Signing -> uncheck Sign the assembly checkbox
Run Code Online (Sandbox Code Playgroud)

  • 我只是喜欢堆栈溢出.99%的问题总是在堆栈溢出的帮助下解决.你们都摇滚!! (6认同)