程序集生成失败 - 引用的程序集没有强名称。为什么其他解决方案不起作用?

发布于 2025-01-08 17:44:41 字数 1427 浏览 0 评论 0原文

这是一个经典问题,很多 描述的解决方案。然而,它们似乎都不适合我。

我在 SharePoint 解决方案中使用 Report.NET 库。添加 Reports.dll 作为引用并编译会导致错误消息“程序集生成失败 - 引用的程序集‘Reports’没有强名称。”然而,我的项目在项目属性中链接了一个 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

我最终得到了一个带有时间戳的新 Reports.dll。但是,将其添加为对我的项目和构建的引用会给出与以前相同的错误消息。 “报告”引用的属性显示“强名称: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

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

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

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

乄_柒ぐ汐 2025-01-15 17:44:41

我刚刚在 vs 2010 中使用以下方法解决了这个问题:

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

I just solved this problem in vs 2010 using this:

Project Properties -> Signing -> uncheck Sign the assembly checkbox
鱼忆七猫命九 2025-01-15 17:44:41

我建议,如果您从命令行明确正确地签署了 Reports.dll 后,VS 仍然说该 dll 未签名;那么它一定引用了错误的文件。

如果您想真正偏执并在签名后仔细检查强命名,请将 Reports.dll 加载到 ildasm 中(您必须双击树中的清单节点并向下滚动以找到 .publickey部分)。或者为了方便起见,只需在 ILSpy 中打开它。

签署reports.dll后;以 XML 文档的形式打开引用项目的 proj 文件(如果您有 VS PowerCommands,则可以右键单击并“编辑项目文件”;否则,您可以卸载该项目,然后使用“打开方式”命令在 VS 中打开它打开文件对话框)并验证对 dll 的引用确实是正确的路径。如果不是,请更正它并重新加载项目。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文