I have 2 arrays in C# and one API in c++ (provided library, no source)
public struct POS_DATA_2D
{
public UInt32 u32_opt;
public Int32 i32_x;
public Int32 i32_y;
public Int32 i32_theta;
}
public struct PNT_DATA_2D
{
public UInt32 u32_opt;
public Int32 i32_x;
public Int32 i32_y;
public Int32 i32_theta;
public Int32 i32_acc;
public Int32 i32_dec;
public Int32 i32_vi;
public Int32 i32_vm;
public Int32 i32_ve;
}
int cnt = 58;
POS_DATA_2D[] pPosarr = new POS_DATA_2D[cnt];
PNT_DATA_2D[] pPntarr = new PNT_DATA_2D[cnt];
The problem is when I call the below API the program crashed. I guessed it accessed array element which isn't correct.
ADCNC_W32.APS168.VelocityPlanning(cnt, ref pPosarr[0], ref pPntarr[0]);
The description of that API
[DllImport("ADCNC.dll")]public static extern Int32
VelocityPlanning(
System.UInt32 PosCount // [IN ] position array count, [1,4294967295]
, ref POS_DATA_2D PosArray // [IN ] position array start pointer, [!NULL]
, ref PNT_DATA_2D PntArray // [OUT] point array start pointer, [!NULL]
);
Please help me to point out the incorrect points. Thanks!