C#调用C++.dll库发生堆栈不平衡的问题。请问如何解决?
这是报错文字:“AcalltoPInvokefunctionhasunbalancedthestack.ThisislikelybecausethemanagedPInv...
这是报错文字:
“ A call to PInvoke function has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.”
.dll库中的函数声明如下:
BOOL WINAPI CH341EppWriteData( // EPP方式写数据: WR#=0, DS#=0, AS#=1, D0-D7=output
ULONG iIndex, // 指定CH341设备序号
PVOID iBuffer, // 指向一个缓冲区,放置准备写出的数据
PULONG ioLength ); // 指向长度单元,输入时为准备写出的长度,返回后为实际写出的长度
。
在C#中调用时声明为:
public delegate Boolean CH341EppWriteData(UInt32 iIndex, IntPtr iBuffer, ref UInt32 ioLength);
总是报错,求大神帮助。。。。。。。 展开
“ A call to PInvoke function has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.”
.dll库中的函数声明如下:
BOOL WINAPI CH341EppWriteData( // EPP方式写数据: WR#=0, DS#=0, AS#=1, D0-D7=output
ULONG iIndex, // 指定CH341设备序号
PVOID iBuffer, // 指向一个缓冲区,放置准备写出的数据
PULONG ioLength ); // 指向长度单元,输入时为准备写出的长度,返回后为实际写出的长度
。
在C#中调用时声明为:
public delegate Boolean CH341EppWriteData(UInt32 iIndex, IntPtr iBuffer, ref UInt32 ioLength);
总是报错,求大神帮助。。。。。。。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询