0

在我的解决方案中,有一个 C# 类库项目(A 项目)。我想在该项目中添加强命名程序集。但是(A 项目)包含另一个 DLL(B.dll)。

我使用 VS2012 x86 Native Tools 命令提示符生成“a.snk”。像这样

sn.exe -k C:\A.snk

我在(A项目)的“AssemblyInfo.cs”中添加了以下代码。然后构建项目。

[组装:ComVisible(真)]

[程序集:AssemblyDelaySign(false)]

[程序集:AssemblyKeyFile("C:\A.snk")]

构建(A 项目)后,出现错误“程序集生成失败——引用的程序集 'B' 没有强名称”。但是(B.DLL)是由第三方创建的。

如何解决?非常感谢。

4

2 回答 2

0

You have a problem. Your only option is to ask the third party to provide a strong name otherwise you won't be able to do it for your application. The point of these strong names is to create some kind of accountability are you going to be accountable for your app if the third party dll is failing or doing things that are not 'normal' ?

This question has been asked before I found something on msdn : https://social.msdn.microsoft.com/Forums/vstudio/en-US/35930958-9775-4e56-bd38-0362d124ffc4/assign-strong-name-to-third-part-dll

于 2015-03-24T08:47:26.713 回答
0

您不必仅仅因为它引用具有强名称的程序集而为您的程序集(A 项目)创建一个强名称。只要不这样做,您就可以毫无问题地编译您的程序集。事实上,所有 BCL 程序集都有强名称,否则无法引用。

但正如 Philip Stuyck 在上面的回答中所说,如果您需要创建一个强名称,您将不得不向您的第三方供应商询问 B.DLL 的签名版本。

于 2015-03-24T08:52:23.413 回答