3 using System
.Reflection
;
5 public class TestAssemblyLoad
{
7 public static int Main ()
9 return TestDriver
.RunTests (typeof (TestAssemblyLoad
));
12 public static int test_0_LoadFileBindingRedirect ()
15 string path1
= Path
.Combine (AppDomain
.CurrentDomain
.BaseDirectory
, "assembly-load-dir1", "LibStrongName.dll");
17 // Try to load from dir1/LibStrongName.dll, but
18 // the assembly-loadfrom-bindingredirect.exe.config redirects all old versions to
19 // be mapped to version 2.0.0.0 which is in the assembly-load-dir2 directory
21 // In old versions of .net binding redirection did not apply to
22 // LoadFile, but since .NET 2 it does.
23 Assembly asm1
= Assembly
.LoadFile (path1
);
25 Console
.Error
.WriteLine ("expected asm1 {0} to not be null", asm1
);
29 Type t1
= asm1
.GetType ("LibClass");
31 Console
.Error
.WriteLine ("expected t1 {0} to not be null", t1
);
35 FieldInfo f1
= t1
.GetField ("OnlyInVersion1");
37 Console
.Error
.WriteLine ("expected not to find field OnlyInVersion1, but got {0}", f1
);
41 FieldInfo f2
= t1
.GetField ("OnlyInVersion2");
44 Console
.Error
.WriteLine ("expected field OnlyInVersion2 not to be null");
48 if (f2
.FieldType
!= typeof(int)) {
49 Console
.Error
.WriteLine ("Field OnlyInVersion2 has type {0}, expected int", f2
.FieldType
);