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 that I get is:
Could not load file or assembly 'ConsoleApplication1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.