blue λ
❔ Loading arbitrary values onto a ILGenerator stack
hey! i'm new to c# and i have a question/issue regarding the ILGenerator.
I am trying to use a function from JS to subscribe to an event handler. What I came up with was extracting the correct argument types using Reflection (from the target event's
Invoke
function) and then creating a DynamicMethod
to call the JS function, using ILGenerator.EmitCall
.
After hours of trying to do this, I noticed something: calling the JS function requires 3 arguments (first one being null), but I only have 2.
Is there a way to load a null value to Ldarg_0
without messing with the arguments of the dynamic method? I took a look at the Opcodes
class (not everything obv) and couldn't find any load operations related to that. any suggestions are appreciated because I really don't know what to do now 🙃65 replies