我在Visual Studio 2005项目中添加了一个弱命名的程序集(它是强命名的)。我现在得到的错误:
"引用程序集'xxxxxxxx'没有强名称"
我需要签署这个第三方程序集吗?
我在Visual Studio 2005项目中添加了一个弱命名的程序集(它是强命名的)。我现在得到的错误:
"引用程序集'xxxxxxxx'没有强名称"
我需要签署这个第三方程序集吗?
当前回答
我在使用NuGet安装的ServiceStack DLL文件时遇到了这个问题。原来还有另一组标记为已签名的DLL文件可用。这不是每个人的答案,但您可能只需要检查程序集的现有签名版本。
其他回答
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
如@Michal Stefanow所说,删除“Signing”选项卡下的“Sign the assembly”复选标记。
Add here是为自己的文件和/或其他人的文件签名的最简单方法。你只需要在“Post-build event命令行”下添加这一行:
"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\signtool.exe" sign /f "$(ProjectDir)\YourPfxFileNameHere.pfx" /p YourPfxFilePasswordHere /d "Your software title here" /du http://www.yourWebsiteHere.com /t http://timestamp.verisign.com/scripts/timstamp.dll /v "$(BaseOutputPath)$(TargetFileName)"
你可以给别人的文件签名,也可以给自己的文件签名,想签多少都行。
为第三方程序集签名对我来说很有效:
引用程序集没有强名称
我了解到,如果链接的文章不再有效,发布步骤是很有帮助的。所有功劳归于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
我正在寻找解决同样问题的解决方案,取消“签署程序集”选项对我有用:
(正如你可能注意到的,截图来自Visual Studio 2010,但希望它能帮助到一些人。)
如何对未签名的第三方程序集进行签名
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.