2 using System.Reflection;
4 using System.Security.Permissions;
8 private const string filename = "library1b";
10 static int GetTypeFalse (Assembly a)
12 string typename = "InheritanceDemand";
13 Type t = a.GetType (typename, false);
15 Console.WriteLine ("*1* Get null for type '{0}' with security.", typename);
18 Console.WriteLine ("*0* Can get type '{0}' with security.", typename);
23 static int GetTypeTrue (Assembly a)
25 string typename = "InheritanceDemand";
26 Type t = a.GetType (typename, true);
27 Console.WriteLine ("*0* Can get type '{0}' with security.", t);
31 static int GetTypes (Assembly a)
33 Type[] ts = a.GetTypes ();
34 Console.WriteLine ("*0* Can get all types from assembly '{0}' loaded. {1} types present.", filename, ts.Length);
41 Assembly a = Assembly.Load (filename);
43 Console.WriteLine ("*2* Couldn't load assembly '{0}'.", filename);
47 string typename = "NoSecurity";
48 Type t = a.GetType (typename);
50 Console.WriteLine ("*3* Cannot get type '{0}' without security.", typename);
54 int err = GetTypeFalse (a);
58 err = GetTypeTrue (a);
65 catch (ReflectionTypeLoadException rtle) {
66 Console.WriteLine ("*4* Expected ReflectionTypeLoadException\n{0}", rtle);
69 catch (SecurityException se) {
70 Console.WriteLine ("*5* Unexpected SecurityException\n{0}", se);
74 Console.WriteLine ("*6* Unexpected Exception\n{0}", e);