Exemple #1
0
		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}");
			}
		}
Exemple #2
0
		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}");
			}
		}
Exemple #3
0
		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}");
				}
			}
		}