public DynamicTypeResolver() { _assemblies = new Dictionary <string, Assembly>(); _loader = new DynamicLoad(); var assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (var asm in assemblies) { _assemblies.TryAdd(asm.GetName().Name, asm); } }
static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) { var assemblyname = new AssemblyName(args.Name).Name; Console.WriteLine(assemblyname); DynamicLoad load = new DynamicLoad(); var assembly = load.Load($"plugin1/{assemblyname}.dll"); /* var assemblyname = new AssemblyName(args.Name).Name; * var assemblyFileName = Path.Combine("plugins", "plugin1", assemblyname + ".dll"); * var assembly = Assembly.LoadFrom(assemblyFileName); */ return(assembly.Item2); }
public static void Main(string[] args) { var test = new DynamicLoad(); var t = test.GetType(); Console.WriteLine(t.AssemblyQualifiedName); var s = "hfdynamic.DynamicLoad2, hfdynamic, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"; var t2 = Type.GetType(s, false); if (t2 == null) { Console.WriteLine("Not found"); } CreateHostBuilder(args).Build().Run(); }