我在Visual Studio 2005项目中添加了一个弱命名的程序集(它是强命名的)。我现在得到的错误:

"引用程序集'xxxxxxxx'没有强名称"

我需要签署这个第三方程序集吗?


当前回答

为第三方程序集签名对我来说很有效:

引用程序集没有强名称

我了解到,如果链接的文章不再有效,发布步骤是很有帮助的。所有功劳归于Hiren Khirsaria:

运行Visual Studio命令提示符并转到DLL所在的目录。 例如,我的DLL位于D:/hiren/Test.dll 现在使用下面的命令创建CIL文件。 D:/hiren> ildasm /all /out=Test。il Test.dll(此命令生成代码库) 生成一个新密钥来对项目进行签名。 D:/hiren> sn -k mykey.snk 现在使用ilasm命令对库进行签名。 D:/hiren> ilasm /dll /key=mykey。snk Test.il

其他回答

情境: 你有方案A B C D在方案X Y中

X中的A、B、C项目 项目A, C, D在Y

我需要在项目A中使用项目C,但后来我不用了。在bin Debug项目A中有C.dll。

如果我编译解决方案X,一切都很好(在这个解决方案中,我删除参考A -> c),但在解决方案Y中,我得到了这个问题。

解决方案是删除项目A中的C.dll bin Debug

如何对未签名的第三方程序集进行签名

Open up Developer Command Prompt for Visual Studio. This tool is available in your Window programs and can be found using the default Windows search. Ensure your prompt has access to the following tools by executing them once: sn ildasm and ilasm Navigate to the folder where your Cool.Library.dll is located sn –k Cool.Library.snk to create a new key pair ildasm Cool.Library.dll /out:Cool.Library.il to disassemble the library move Cool.Library.dll Cool.Library.unsigned.dll to keep the original library as a back-up ilasm Cool.Library.il /dll /resource=Cool.Library.res /key=Cool.Library.snk to reassemble the library with a strong name powershell -command "& {[System.Reflection.AssemblyName]::GetAssemblyName($args).FullName} Cool.Library.dll" to get the assembly fully qualified name. You will need this bit if you have to reference the DLL in external configuration files like web.config or app.config.

为第三方程序集签名对我来说很有效:

引用程序集没有强名称

我了解到,如果链接的文章不再有效,发布步骤是很有帮助的。所有功劳归于Hiren Khirsaria:

运行Visual Studio命令提示符并转到DLL所在的目录。 例如,我的DLL位于D:/hiren/Test.dll 现在使用下面的命令创建CIL文件。 D:/hiren> ildasm /all /out=Test。il Test.dll(此命令生成代码库) 生成一个新密钥来对项目进行签名。 D:/hiren> sn -k mykey.snk 现在使用ilasm命令对库进行签名。 D:/hiren> ilasm /dll /key=mykey。snk Test.il

我添加了NuGet包“StrongNamer”,我的问题解决了。

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.