Calling varargs method via DynamicMethod
问题 I'm trying to call unmanaged printf-like function using DynamicMethod. At runtime I get a BadImageFormatException:Index not found. (Exception from HRESULT: 0x80131124) Is this a limitation of runtime or my emited code is wrong? public class Program { [DllImport("msvcrt40.dll",CallingConvention = CallingConvention.Cdecl)] public static extern int printf(string format, __arglist); static void Main(string[] args) { var method = new DynamicMethod("printf", typeof(void), new Type[0], true); var il