VB.NET调用dll问题
我用VB。net调用VC开发的动态库时出错:
头文件:
void WINAPI ICC_set_NAD(HANDLE fd,unsigned char nad);
unsigned char * WINAPI CHexToBin(
unsigned char *bin,
unsigned char *asc,
unsigned int len
);
VB声明:
Public Declare Function ICC_set_NAD Lib "wdCrwx.dll" Alias "ICC_set_NAD" (ByVal fd As IntPtr, ByVal nad As Byte)
Public Declare Function CHexToBin Lib "wdCrwx.dll" Alias "CHexToBin" (ByRef bin As StringBuilder, ByVal asc As String, ByVal len As ULong) As StringBuilder
vb调用:
ICC_set_NAD(fd, &H13)
报错:PInvoke 限制: 无法返回变量。
CHexToBin(resp, "123456", 6)
报错:对 PInvoke 函数“WindowsApplication1!WindowsApplication1.Module1::CHexToBin”的调用导致堆栈不对称。原因可能是托管的 PInvoke 签名与非托管的目标签名不匹配。请检查 PInvoke 签名的调用约定和参数与非托管的目标签名是否匹配。
请教各位如何解决?