关于Winform动态调用Delphi DLL问题
Delphi DLL:
DLL名称:TestInterface.dll
DLL接口名称:TestMethod
DLL接口声明:Function TestMethod(ax1, ar1 : PChar) : Integer;
ax1和ar1的参数类型都是PChar
我在C#中是这样声明的:
[DllImport("TestInterface.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi, PreserveSig = false)]
public static extern int TestMethod(IntPtr ax1, IntPtr ar1);
调用TestMethod一直报以下错误:
对 PInvoke 函数“HYOutRegiCashFacade!HYOutRegiCashFacade.Business.PrintInterface::TestInterface”的调用导致堆栈不对称。原因可能是托管的 PInvoke 签名与非托管的目标签名不匹配。请检查 PInvoke 签名的调用约定和参数与非托管的目标签名是否匹配。