Answer the question
In order to leave comments, you need to log in
How to call a virtual method in C# from IL?
Good afternoon.
Initial data: there is a MethodInfo of a virtual method, for example, obtained from the interface
Task: it is necessary to assemble a function that calls virtual methods with the same signature using the calli
instruction implements a virtual function lookup and makes a call?
For example, if the method is non-virtual and the address of the method, for example, is passed as the first argument:
ldftn calli <br/>
можно заменить на<br/>
<code>ldarg.0<br/>
conv.i<br/>
calli <br/>
В данном случае адрес метода получается следующим образом: <br/>
<code>MethodInfo m;<br/>
var ptr = m.MethodHandle.GetFunctionPointer()</code></code>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question