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_LoadBytesBindingRedirect ()
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-load-bytes-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 // Load(byte[]), but since .NET 2 it does.
23 byte[] bytes1
= File
.ReadAllBytes (path1
);
24 Assembly asm1
= Assembly
.Load (bytes1
);
26 Console
.Error
.WriteLine ("expected asm1 {0} to not be null", asm1
);
30 Type t1
= asm1
.GetType ("LibClass");
32 Console
.Error
.WriteLine ("expected t1 {0} to not be null", t1
);
36 FieldInfo f1
= t1
.GetField ("OnlyInVersion1");
38 Console
.Error
.WriteLine ("expected not to find field OnlyInVersion1, but got {0}", f1
);
42 FieldInfo f2
= t1
.GetField ("OnlyInVersion2");
45 Console
.Error
.WriteLine ("expected field OnlyInVersion2 not to be null");
49 if (f2
.FieldType
!= typeof(int)) {
50 Console
.Error
.WriteLine ("Field OnlyInVersion2 has type {0}, expected int", f2
.FieldType
);