I generate assemblies dynamically and invoke methods from those assemblies. I use both visual studio and mono. Sometimes, I do something wrong with ILGenerator.Emit, and get an InvalidProgramException when trying to invoke a method.
Is there any way to get the faulty instruction?
So far I have to disassemble the assembly with ILSpy and manually go through the IL which is OK when the generated method is simple.
Unfortunately, sometimes the generated method contains hundreds of MSIL instructions, and it gets harder to indentify the error.
I wonder if there is anything built-in somewhere to help me.
Unfortunately peverify is not very helpful as I generate unsafe code (with pointers). I therefore get this kind of errors:
Unmanaged pointers are not a verifiable type
In addition, some of those errors only happen with mono, and not within visual studio.
Thanks