我在Visual Studio 2005项目中添加了一个弱命名的程序集(它是强命名的)。我现在得到的错误:
"引用程序集'xxxxxxxx'没有强名称"
我需要签署这个第三方程序集吗?
我在Visual Studio 2005项目中添加了一个弱命名的程序集(它是强命名的)。我现在得到的错误:
"引用程序集'xxxxxxxx'没有强名称"
我需要签署这个第三方程序集吗?
当前回答
ilmerge使用。ilmerge来自微软,但它没有随Visual Studio或sdk一起发布。不过你可以从这里下载。还有一个GitHub存储库。你也可以从NuGet安装:
PM> Install-Package ilmerge
使用方法:
ilmerge assembly.dll /keyfile:key.snk /out:assembly.dll /targetplatform:v4,C:\Windows\Microsoft.NET\Framework\v4.0.30319 /ndebug
如果需要,你可以使用sn(从Visual Studio)生成你自己的密钥文件:
sn -k key.snk
其他回答
我正在寻找解决同样问题的解决方案,取消“签署程序集”选项对我有用:
(正如你可能注意到的,截图来自Visual Studio 2010,但希望它能帮助到一些人。)
我已经编写了一个工具来自动强名称标记程序集,包括您没有源代码的程序集或已放弃的项目。它以一种简单的方式使用了答案中描述的许多技术,没有任何现有工具或过时说明的缺陷或缺陷。
.NET程序集强- name签名者
我希望这可以帮助任何需要签署第三方程序集的人,而不必经过重重困难才能到达那里。
I had this issue for an app that was strongly named then had to change it in order to reference a non-strongly named assembly, so I unchecked 'Sign the assembly' in the project properties Signing section but it still complained. I figured it had to be an artifact somewhere causing the problem since I did everything else correctly and it was just that. I found and removed the line: [assembly: AssemblyKeyFile("yourkeyfilename.snk")] from its assemblyInfo.cs file. Then no build complaints after that.
对我来说,我的问题是我有两个相同的NuGet包安装了不同的版本。
对我来说,问题在于没有强名称的NuGet包。解决方案是从NuGet安装StrongNamer,它会自动向所有引用的程序集添加强名称。只是简单地在项目中引用它修正了我的问题。