Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / tests / bug-322722_dyn_method_throw.2.cs
1 using System;
2 using System.Reflection;
3 using System.Reflection.Emit;
4
5 public class MyException : Exception {
6
7 }
8
9 class Driver {
10         public static int Main()
11         {
12                 DynamicMethod method_builder = new DynamicMethod ("ThrowException" , typeof (void), new Type[0], typeof (Driver));
13                 ILGenerator ilg = method_builder.GetILGenerator ();
14
15
16                 ilg.Emit (OpCodes.Newobj,  typeof (MyException).GetConstructor (new Type[0]));
17                 ilg.Emit (OpCodes.Throw);
18
19                 try {
20                         method_builder.Invoke (null, null);
21                         return 2;
22                 } catch (TargetInvocationException tie) {
23                         if(! (tie.InnerException is MyException))
24                                 return 3;
25                 }
26
27                 return 0;
28         }
29 }