From: "Jonathan Ross" <[EMAIL PROTECTED]>
Okay, for the last 4 hours I've been stuck on calling a dynamic method
from
another dynamic method. Following is my code, which errors out for some
reason unknown to me.
The error message "Common Language Runtime detected an invalid program."
almost certainly means that you've messed up the stack in your IL. And if
you look at the following sequence, you'll see that there is an extra item
left on the stack at the conclusion of the method, which makes for an
invalid program.
ilB.Emit(OpCodes.Call, MethInfoA);
ilB.Emit(OpCodes.Ldc_I4_0);
ilB.Emit(OpCodes.Ret);
There is a significant difference between MSIL and x86 assembly language --
in MSIL, everything including return values are on the stack. This means
that unused return values must be manually cleaned up.
To fix this, either return the value of the call to A from B by removing the
Ldc_I4_0, or add an extra "Pop" after the call to A.
--
Curt Hagenlocher
[EMAIL PROTECTED]
===================================
This list is hosted by DevelopMentorĀ® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com