Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug InvalidProgramException on emited code for DynamicMethod

After searching the stackoverflow plus googling alot, the solutions offered for debugging code that gets emitted for DynamicMethods seems outdated and very unwieldy.

Surely in the intervening 4 years or more since LCG (light-weight code generation) was released, someone must have found a better way.

What do you find is the easiest way to verify the dynamic IL that you write and debug it?

Do you use peverify or ILDasm or something else? Those 2 tools require writing the assembly to disk but DynamicMethod doesn't offer any direct way to do that.

Apparently WinDbg aso offers a way to see the IL but that's very awkward to deal with that.

Something like a plugin to VisualStudio 2010 will be ideal.

Any ideas?

like image 450
Wayne Avatar asked Jun 26 '12 14:06

Wayne


1 Answers

You can use ILGenerator.MarkSequencePoint to allow debugging step by step your emitted code.

like image 84
Tony THONG Avatar answered Sep 28 '22 00:09

Tony THONG