Question

I'm working in C# .Net 4.0

I have the following parts of the architecture:

  1. three "general" DLLs : X.dll , Y.dll, and Z.dll
  2. one "particular" DLL (A.dll) that is referencing the "general" DLLs
  3. one C# application that dynamically loads the A.dll (I use System.Reflection.Assembly ass = Assembly.LoadFrom(filename))

Since the application doesn't explicitly reference those "general" DLLs, I get an exception.

So my question is whether there is any chance to create the A.dll the way that would allow loading this DLL without the need to load those "general" DLLs. It seems that I can't transfer my A.dll without remembering about all the DLLs it is referencing.

I believe there is a good logic behind the way how it is done in C# 4.0, but maybe there are some exceptions to this?

Thanks for any help!

Était-ce utile?

La solution

The problem here is your application only loads A.dll therefore that's the only DLL that's copied into the output directory so when A attempts to access code from X it fails because the app doesn't know where X is therefore can't load it.

The easiest solution here would be to install the other "general" DLLs into the GAC. Or alternatively, just ship the "general" DLLs with your app because they won't be loaded unless you use A anyway, although, they are unnecessary bloat on your install/app size if they aren't required.

Autres conseils

The problem is same what described above

"The problem here is your application only loads A.dll therefore that's the only DLL that's copied into the output directory so when A attempts to access code from X it fails because the app doesn't know where X is therefore can't load it."

But you can put these three "general" DLLs : X.dll , Y.dll, and Z.dll into a folder say genDllFolder

    String genDllFolder = "yourpath/genDllFolder";
    AppDomain.CurrentDomain.AppendPrivatePath(genDllFolder);
    System.Reflection.Assembly ass = Assembly.LoadFrom(filename));
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top