Marshal.SizeOf(struct[])获取不到其大小
Inte易做图ce.ATTGUARDRECORD[] pRecordBuffer = new Inte易做图ce.ATTGUARDRECORD[nCount];IntPtr pBuffer = Marshal.AllocHGlobal(Marshal.SizeOf(pRecordBuffer));
Inte易做图ce.GetData(m_pActReturn, pBuffer, nLength);
Type myType = pRecordBuffer.GetType();
pRecordBuffer = (Inte易做图ce.ATTGUARDRECORD[])Marshal.PtrToStructure(pBuffer, myType);
上述代码运行出错:型別 'Test2.Inte易做图ce+ATTGUARDRECORD[]' 不可以當做 Unmanaged 結構來封送處理; 因此無法計算有意義的大小或位移。
Inte易做图ce.ATTGUARDRECORD结构体如下:
public struct ATTGUARDRECORD
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 7)]
public byte[] tPersonID;
public int nYear;
public int nMonth;
public int nDay;
public int nHour;
public int nMinute;
public int nSecond;
public int bOnDuty;
public int bBC;
public int nAdr;
}
以上问题不知如何解决,请高手们指点一下,谢谢! --------------------编程问答-------------------- 沒人頂,唉!算了,沙發自己坐了
补充:.NET技术 , C#