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

标签 .net visual-studio-2010 sharepoint code-signing

这是一个经典问题,有 numerous解决方案described .但是,它们似乎都不适合我。

我在 SharePoint 解决方案中使用 Report.NET 库。添加 Reports.dll 作为引用并编译会导致错误消息“程序集生成失败 - 引用的程序集 'Reports' 没有强名称。”但是,我的项目在项目属性中链接了一个 key.snk。因此,我尝试使用此 key 文件对 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。但是,将其添加为对我的项目和构建的引用会给出与以前相同的错误消息。 “报告”引用的属性显示“强名称:假”。

不要因为一点麻烦而气馁,我尝试使用强命名实用程序重新签署程序集:
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 时仍然会收到原始错误消息。

最佳答案

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

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

关于.net - 程序集生成失败 - 引用的程序集没有强名称。为什么其他解决方案不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9391452/

相关文章:

c# - 在 Windows Mobile 上访问可用 Wifi 应用程序列表

c# - Visual Studio 2010 在崩溃时清空文件

c++ - Visual Studio : Disable Automatic Initialization

asp.net - 发布 Web 应用程序时缩小 Asp.Net 中的 CSS 和 JS

sharepoint - 将 ListItem 添加到 Sharepoint 2007 中的列表

javascript - 请求失败。来自服务器的意外响应。 Sharepoint 2013 在线出现空错误

c# - .NET 的分布式文件系统

.net - C# 中的低级编程

javascript - 如何使用 javascript 而不是 jquery 获取 td 标签内 <nobr> 标签的值

.net - 如何确定 System.Diagnostics.Process 是 32 位还是 64 位?