C#引入外部非托管类库时,有时候会出现“对PInvoke函数调用导致堆栈不对称。原因可能是托管的 PInvoke 签名与非托管的目标签名不匹配”的报错。

通常在DllImport标签内加入属性CallingConvention=CallingConvention.Cdecl即可解决该问题。

如:     
  [DllImport("AutoAnalyse.dll", EntryPoint="Measure", CallingConvention=CallingConvention.Cdecl)]  
       public static extern string Measure(string baseKey, string project);

相关文章:

  • 2021-06-15
  • 2021-08-15
  • 2022-12-23
  • 2022-12-23
  • 2021-04-13
  • 2021-12-19
  • 2022-01-02
猜你喜欢
  • 2021-12-07
  • 2022-12-23
  • 2022-12-23
  • 2022-02-16
  • 2021-06-28
  • 2021-11-03
  • 2022-12-23
相关资源
相似解决方案