结构体指针的问题,寻求高手
delegate void jdkCALLBACK(int nType, ref IntPtr pContext);
是一个回调函数,在调用C++DLL的方法里会回调一个函数出来,目前的问题在于回调出来的指针类型没有办法转换成结构体,结构体如下:
public struct test
{
public int m_devId;
public char[] m_pstrIp;
public int m_sPort;
}
当回调函数出现时,使用结构体指针转换这里出错
testentries = (test)Marshal.PtrToStructure(pContext, typeof(test));
出错信息为:
运行库遇到了错误。此错误的地址为 0x79ee2552,在线程 0x63c 上。错误代码为 0xc0000005。此错误可能是 CLR 中的 bug,或者是用户代码的不安全部分或不可验证部分中的 bug。此 bug 的常见来源包括用户对 COM-interop 或 PInvoke 的封送处理错误,这些错误可能会损坏堆栈。
我怀疑是在封送结构体指针的时候出了错误,不知道该如何操作,所以请教各位高手