[2020-02] Avoid following invalid pointers in mono_w32process_get_modules on Darwin...
[mono-project.git] / mono / tests / reflection-load-with-context.cs
blobf55bd0b96d024767a2e9325b7d6339d8b8498906
1 using System;
2 using System.Reflection;
3 using System.IO;
5 class Driver {
6 static int Main () {
7 var src = Path.GetDirectoryName (typeof (Driver).Assembly.Location);
8 var dep_asm = Assembly.UnsafeLoadFrom (Path.Combine (src, "reflection-load-with-context-lib.dll"));
9 var type = dep_asm.GetType ("B.ClassB");
10 var attr_type = dep_asm.GetType ("B.MyAttribute");
12 try {
13 Activator.CreateInstance (type);
14 } catch (Exception) {
15 return 1;
18 try {
19 type.GetCustomAttributes (attr_type, false);
20 } catch (Exception) {
21 return 2;
23 return 0;