C#调用C++dll含有指针的问题
编写了一段程序,C++里这么写的float ITU_raoshe_DLL(int* grid, int row, int column, float X1, float Y1, float X2, float Y2, float f, float ht, float hr);
C#调用这么写的[DllImport("ITU_raoshe_DLL_1.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern float ITU_raoshe_DLL(Intptr grid, int row, int column, float X1, float Y1, float X2, float Y2, float f, float ht, float hr);
调用函数:int[,] data = new int[Column, Row];
IntPtr pointer = Marshal.UnsafeAddrOfPinnedArrayElement(data, 0);
result[i, j] = CPPDLL.ITU_raoshe_DLL(pointer, Row, Column, X[j], Y[j], X[i], Y[i], f1[j], H[j], H[i]);
但是运行时报错:尝试读取或写入受保护的内存这通常指示其他内存已损坏。
是什么问题啊,哪位高手能帮忙解释下,谢啦