Before enter, sorry for my bad english...
I am making some program that need to implement plugin structure. Loader.exe is a main application, Plugin.dll is a plugin class library. Plugin.dll requires Depend.dll.
I want to forcing load Depend.dll in specific path, without GAC or appdomain base directory, etc. I preload the Depend.dll using Assembly.LoadFile before load Plugin.dll, but assembly cannot detect loaded assembly-Depend.dll. It throws System.IO.FileNotFoundException at Plugin.Start().
Is it possible to preload referenced assembly without adding event handler to AssemblyResovle?
I cannot use AssemblyResolve handler.
Depend.dll
using System;
namespace Depend
{
public class Hello
{
public void World()
{
Console.WriteLine("Hello, world!");
}
}
}
Plugin.dll
using Depend;
namespace Plugin
{
public class Plugin
{
public void Start()
{
new Hello().World();
}
}
}
Loader.exe
string path = Environment.CurrentDirectory;
Assembly.LoadFile(Path.Combine(path, "..\\Depend.dll"));
Assembly asm = Assembly.LoadFile(Path.Combine(path, "Plugin.dll"));
Type typ = asm.GetType("Plugin.Plugin");
typ.GetMethod("Start").Invoke(Activator.CreateInstance(typ), null);
Aucun commentaire:
Enregistrer un commentaire