According to the documentation for calli
, the overload of EmitCalli()
you're using should be used only for calling unmanaged code. For managed code, you should call an overload that takes one more parameter and set it to null
(unless you're using varagrg
, which is extremely rare):
ilg.EmitCalli (OpCodes.Calli, System.Runtime.InteropServices.CallingConvention.HasThis, typeof<int>, [|typeof<int>|], null)