[ACCEPTED]-Reflection.Net: how to load dependencies?-add-on
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.
Couple of options:
- You can attach to
AppDomain.AssemblyResolve
to help the CLR resolve the assembly. - You could look into isolating add-ins into their own
AppDomain
(seeSystem.AddIn
namespace and this website).
0
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
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.
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
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.