3 using System
.Security
.Policy
;
6 public static int Main ()
8 var dir1
= Path
.GetDirectoryName (typeof (Test
).Assembly
.Location
);
9 var dir2
= "appdomain-marshalbyref-assemblyload2";
10 var domain
= CreateDomain (dir2
);
11 var path1
= Path
.Combine (dir1
, "MidAssembly.dll");
12 object o
= domain
.CreateInstanceFromAndUnwrap (path1
, "MidAssembly.MidClass");
13 var mc
= o
as MidAssembly
.MidClass
;
14 var l
= new LeafAssembly
.Leaf ();
15 /* passing Leaf to MidMethod should /not/ cause
16 * place2/LeafAssembly.dll to be loaded in the new remote
19 /* this line will pre-load place1/LeafAssembly.dll into the
22 mc
.ForceLoadFrom (Path
.Combine (dir1
, "LeafAssembly.dll"));
23 /* This method calls a class from LeafAssembly (which is only
24 * defined in the place1 version of the class), so if the
25 * place2 version had been loaded instead, it will trigger a
26 * MissingMethodException */
31 public static AppDomain
CreateDomain (string newpath
)
33 var appDomainSetup
= new AppDomainSetup ();
34 appDomainSetup
.ApplicationBase
= newpath
;
35 var appDomain
= AppDomain
.CreateDomain ("MyDomainName", new Evidence (), appDomainSetup
);