C#:用强名称签名DLL(它的依赖关系?) [英] C#: Signing DLL with strong name (what about its dependencies?)
问题描述
前一段时间,我询问过DLL导致异常当调用引用另一个DLL的方法时。那个时候我没有任何线索,但是现在我想可能会导致问题。
A while ago I asked about "DLL caused an exception" when calling a method that references another DLL. On that time I had no clues but now I think what may be causing the problem.
假设我有一个 EXE
调用一个 DLL1
,这需要一个 DLL2
。当我使用强名称签名 DLL1
时,由于某种原因,所有调用 DLL2
的方法开始返回下面的错误:
Assume I have an EXE
calling a DLL1
which requires a DLL2
. When I signed DLL1
with a strong name, for some reason all calls to DLL2
's methods started returning the error below:
System.Exception: Error while trying to call method X from DLL1.
---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.IO.FileLoadException: Could not load file or assembly 'DLL2', Version=2.1.5899, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required.
这是否意味着我必须强制命名依赖链上的每个DLL?
我不得不签署第一个DLL,否则我会在 regasm
中发出警告。
I had to sign the first DLL because otherwise I would get a warning during regasm
.
推荐答案
是
签名的程序集不能调用无符号的程序集。这是信任链的一部分,它确实意味着您必须签署所签署的程序集的所有依赖项。
Yes
a signed assembly cannot call an unsigned assembly. That's part of the trust chain and it does indeed mean you will have to sign all dependencies of your signed assembly.
这篇关于C#:用强名称签名DLL(它的依赖关系?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!