Ładowanie zestawu macierzy bajtów

Eksperymentuję z ładowaniem zespołu przy użyciu tylko tablic bajtów, ale nie wiem, jak go poprawnie uruchomić. Oto konfiguracja:

public static void Main() 
{
    PermissionSet permissions = new PermissionSet(PermissionState.None);
    AppDomainSetup setup = new AppDomainSetup { ApplicationBase = Environment.CurrentDirectory };
    AppDomain friendlyDomain = AppDomain.CreateDomain("Friendly", null, setup, permissions);

    Byte[] primary = File.ReadAllBytes("Primary.dll_");
    Byte[] dependency = File.ReadAllBytes("Dependency.dll_");

    // Crashes here saying it can't find the file.
    friendlyDomain.Load(dependency);

    AppDomain.Unload(friendlyDomain);

    Console.WriteLine("Stand successful");
    Console.ReadLine();
}

Stworzyłem dwie makiety i zmodyfikowałem ich rozszerzenie na „.dll_” celowo, aby system nie mógł znaleźć plików fizycznych. Obieprimary idependency wypełnij poprawnie, ale kiedy próbuję zadzwonić doAppDomain.Load metoda z danymi binarnymi, wraca z:

Could not load file or assembly 'Dependency, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

Dlaczego miałby szukać pliku w systemie?

AKTUALIZACJA

Z drugiej strony wydaje się działać:

public class Program {
    public static void Main() {
        PermissionSet permissions = new PermissionSet(PermissionState.Unrestricted);
        AppDomainSetup setup = new AppDomainSetup { ApplicationBase = Environment.CurrentDirectory };
        AppDomain friendlyDomain = AppDomain.CreateDomain("Friendly", null, setup, permissions);

        Byte[] primary = File.ReadAllBytes("Primary.dll_");
        Byte[] dependency = File.ReadAllBytes("Dependency.dll_");

        // Crashes here saying it can't find the file.
        // friendlyDomain.Load(primary);

        Stage stage = (Stage)friendlyDomain.CreateInstanceAndUnwrap(typeof(Stage).Assembly.FullName, typeof(Stage).FullName);
        stage.LoadAssembly(dependency);

        Console.WriteLine("Stand successful");
        Console.ReadLine();
    }

}

public class Stage : MarshalByRefObject {
    public void LoadAssembly(Byte[] data) {
        Assembly.Load(data);
    }
}

Wygląda na to, że istnieje różnica między nimiAppDomain.Load iAssembly.Load.

questionAnswers(3)

yourAnswerToTheQuestion