C#: Signing DLL with strong name (what about its dependencies?)

家住魔仙堡 提交于 2020-01-07 02:48:13

问题


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.

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.

Does this mean I have to strongly name every DLL along the dependency chain?

I had to sign the first DLL because otherwise I would get a warning during regasm.


回答1:


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.



来源:https://stackoverflow.com/questions/35631136/c-signing-dll-with-strong-name-what-about-its-dependencies

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!