I've been doing a few changes to an assembly now and one of them is causing 
big trouble. I could insert several new instructions throughout all methods 
and everything was fine.

When I replace a ldstr instruction with an ldsfld instruction, it fails in 
a few cases (10 out of thousands). I use ILProcessor.Replace, but a 
combination of InsertAfter and then Remove also fails with the same verify 
errors.

PEVerify gives me the following types of errors from all over the assembly:

* jmp / exception in the middle of an instruction
* The stack depth depends on the path
* Stack overflow

(Rough translations from my localised PEVerify)

Where do these errors come from? ILSpy fails to show me the IL code for the 
first error type. And I cannot see any problem from reading the IL code at 
the other errors. Could Cecil generate invalid code here and needs to be 
fixed (I'm using 0.9.5 release) or could this well be my fault by putting 
instructions in a context where I shouldn't do this? How can I detect such 
contexts where not to do anything with instructions? It seems to work 
everywhere and Cecil (or whatever) even seems to update all branch and 
switch offsets accordingly. At least this has worked in many cases already 
and the processed application was still running fine.

I see my modifications in the IL code all over the place, but only very few 
of them cause problems.

-- 
-- 
--
mono-cecil
--- 
You received this message because you are subscribed to the Google Groups 
"mono-cecil" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to