[ACCEPTED]-Reflection.Net: how to load dependencies?-add-on

Accepted answer
Score: 49

If MyTools.dll is located in the same directory as 3 Addon.dll, all you need to do is call Assembly.LoadFrom instead of 2 Assembly.LoadFile to make your code work. Otherwise, handling 1 the AppDomain.AssemblyResolve event is the way to go.

Score: 1

Couple of options:

  1. You can attach to AppDomain.AssemblyResolve to help the CLR resolve the assembly.
  2. You could look into isolating add-ins into their own AppDomain (see System.AddIn namespace and this website).

0

Score: 1

Have you looked into using an Inversion Of Control container? I 4 use Castle Windsor with an external Boo 3 file that lets me easily extend the applcation 2 without having to recompile or worry about 1 supplying dependencies

Score: 1

You can use reflection to access the private 6 Assembly._GetReferencedAssemblies().

Although, the method could change in a future 5 version of the .NET framework, it doesn't 4 seem likely—ASP.NET heavily depends on it, though 3 it's possible they could move it from mscorlib to 2 System.Web which is the only assembly that I know 1 of from where the method is referred to.

Score: 1

Assembly.LoadFrom works well until I try 4 to use a webService in my addon, I had had 3 a "Unable to cast object of type 'X' to type 'X'" exception.

It's ugly, but i will use 2 Assembly.LoadFile with the AppDomain.AssemblyResolve.

Thanks 1 guys.

More Related questions