public static void Load(AppDomain domain, string file, Action<Assembly> callback) { Asm asm = new Asm() { asmfile = file, handler = callback }; try { domain.DoCallBack(new CrossAppDomainDelegate(asm.loadAsmFile)); } catch (Exception ex) { Console.WriteLine($"Failed to load one of the assembly into domain {domain.FriendlyName}: {ex.Message}"); } }
public static void Load(AppDomain domain, byte[] assemblyBytes, Action<Assembly> callback) { Asm asm = new Asm() { asmbytes = assemblyBytes, handler = callback }; try { domain.DoCallBack(new CrossAppDomainDelegate(asm.loadAsmBytes)); } catch (Exception ex) { var iex = ex; while (iex.InnerException != null) { iex = iex.InnerException; } Console.WriteLine($"Failed to load one of the assembly into domain {domain.FriendlyName}: {iex.Message}"); } }
public static void Unload(AppDomain domain, Action<Assembly> callback) { if (callback != null) { Asm asm = new Asm() {domain = domain, handler = callback}; try { log.i($"Unloading {domain.FriendlyName}: {domain.BaseDirectory}"); domain.DoCallBack(new CrossAppDomainDelegate(asm.unloadDomain)); } catch (Exception ex) { log.i($"Failed to unload domain {domain.FriendlyName}: {ex.Message}"); } } }