protected override Assembly Load(AssemblyName assemblyName) { if (assemblyName.Name == "Dahomey.Json") { TestLoadContext tlc = new TestLoadContext(assemblyName.ToString()); Program.AddContext(tlc); return(tlc.LoadFromAssemblyPath(Path.GetFullPath("Dahomey.Json.dll"))); } return(base.Load(assemblyName)); }
static void CallJson() { TestLoadContext tlc = new TestLoadContext("LibraryLoaded"); var asm = tlc.LoadFromAssemblyPath(Path.GetFullPath("LibraryLoaded.dll")); AddContext(tlc); var prg = asm.DefinedTypes.Where(x => x.Name == "Program").First(); var test = prg.DeclaredMethods.Where(x => x.Name == "Test").First(); test.Invoke(null, null); }