dialex dialex - 9 days ago 5
C# Question

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

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
.

Answer

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.