using System.Reflection.Emit; ILGenerator il = ... // create an ILGenerator object Label tryBlockEnd = il.BeginTryCatchFinally(); Label outOfTryBlock = il.DefineLabel(); // emit try block code here il.MarkLabel(outOfTryBlock); // emit catch block code here il.MarkLabel(tryBlockEnd); il.BeginFinallyBlock(); // emit finally block code here il.EndExceptionBlock();
using System.Reflection.Emit; ILGenerator il = ... // create an ILGenerator object Label tryBlockEnd = il.BeginExceptionBlock(); // emit try block code here il.BeginFinallyBlock(); // emit finally block code here il.EndExceptionBlock();Package/library: System.Reflection.Emit.