[netcore] Ongoing work. (#13391)
[mono-project.git] / mono / tests / bug-322722_dyn_method_throw.2.cs
blobc9e0cf3c52f3e00c898cef683d183a202c00f50e
1 using System;
2 using System.Reflection;
3 using System.Reflection.Emit;
5 public class MyException : Exception {
9 class Driver {
10 public static int Main()
12 DynamicMethod method_builder = new DynamicMethod ("ThrowException" , typeof (void), new Type[0], typeof (Driver));
13 ILGenerator ilg = method_builder.GetILGenerator ();
16 ilg.Emit (OpCodes.Newobj, typeof (MyException).GetConstructor (new Type[0]));
17 ilg.Emit (OpCodes.Throw);
19 try {
20 method_builder.Invoke (null, null);
21 return 2;
22 } catch (TargetInvocationException tie) {
23 if(! (tie.InnerException is MyException))
24 return 3;
27 return 0;