Create custom AppDomain and add assemblies to it
How can I create an appdomain, add assemblies to it, then destroy that app domain? This is what I have tried: static void Main(string[] args) { string pathToExe = @"A:\Users\Tono\Desktop\ConsoleApplication1.exe"; AppDomain myDomain = AppDomain.CreateDomain("MyDomain"); Assembly a = Assembly.Load(System.IO.File.ReadAllBytes(pathToExe)); myDomain.Load(a.FullName); // Crashes here! } I have also tried: myDomain.Load(File.ReadAllBytes(pathToExe)); how can I add an assembly to the appdomain. Once I do that I can find the method via reflection execute it and then destroy the appdomain The exception