A call to PInvoke has unbalanced the stack… dll import fails even with Cdecl
问题 Aha, this question is all over stack overflow so I've already proceeded to add CallingConvention = CallingConvention.Cdecl which has worked just fine for other libraries I've had to import but in this case, nothing changes and it still fails with the same error message. The original code for this came out of a .net 3.5 project and works perfectly fine: [DllImport("Compiled DSP.dll")] private static extern int fnGetConfigParam(int nID, ref stParamInt pstParam); [DllImport("Compiled DSP.dll")]