Are there any online examples that show how to implement try and catch
blocks with Cecil's ExceptionHandlers? I want to use it to add catch
blocks around existing methods, but there were no examples of this in
the documentation. I want to take a method like:

public void SomeMethod()
{
   // Original body
   Console.WriteLine("Hello, World!");
}

and use Cecil to convert it into:

public void SomeMethod()
{
   try
   {
     // Original body
     Console.WriteLine("Hello, World!");
   }
   catch(Exception ex)
   {
       throwExceptionAt(myHandler);
   }
}

Now, I noticed that the ExceptionHandler class has Instruction
properties that mark the start and end of each respective try, filter,
and handler (presumably the catch) block. In order to add a custom try-
catch block, do I just have the handler point to the respective start
and end of each block type in the modified method, or am I missing
something here?

--~--~---------~--~----~------------~-------~--~----~
--
mono-cecil
-~----------~----~----~----~------~----~------~--~---

Reply via email to