我在Visual Studio 2005项目中添加了一个弱命名的程序集(它是强命名的)。我现在得到的错误:
"引用程序集'xxxxxxxx'没有强名称"
我需要签署这个第三方程序集吗?
我在Visual Studio 2005项目中添加了一个弱命名的程序集(它是强命名的)。我现在得到的错误:
"引用程序集'xxxxxxxx'没有强名称"
我需要签署这个第三方程序集吗?
当前回答
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.
其他回答
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.
如何对未签名的第三方程序集进行签名
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.
展开使用“没有强名称键”的项目的项目文件,寻找.snk文件(. strongnamekey)。
在Windows资源管理器中浏览这个文件(这样你就知道它在哪里了)。
回到Visual Studio中那个没有“强名称键”的项目,做
右键单击项目文件 选择属性 选择“签名选项卡”(在左侧) 单击“签署程序集”复选框 然后<Browse>到前面找到的.snk文件
这样应该可以了。这为我解决了一个问题,在同一个解决方案中,在另一个项目中使用一个表单。
我希望这能有所帮助。
首先,确保解决方案中所有项目的所有NuGet包都是相同的版本。例如,您不希望一个项目引用NLog 4.0.0.0,而另一个项目引用NLog 4.1.0.0。然后尝试重新安装NuGet包
Update-Package -reinstall
我的程序集A引用了三个第三方程序集,而我的程序集B也引用了A,其中只有两个被包括在引用中。
缺少对第三方程序集的引用是由update package命令添加的,错误消失了。
对我来说,问题在于没有强名称的NuGet包。解决方案是从NuGet安装StrongNamer,它会自动向所有引用的程序集添加强名称。只是简单地在项目中引用它修正了我的问题。