日期:2014-05-18 浏览次数:20892 次
[StructLayout(LayoutKind.Sequential)] public struct STAGINFOPARAM { byte metaData; UInt16 uEPCLength; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)] Byte[] ucaEPC; UInt16 uTagCRC; }; [StructLayout(LayoutKind.Sequential)] public struct SREADINVENTORYTAGINFORSPPARAM { Byte ucStatus; UInt16 uMetadataFlag; Byte ucOption; Byte ucTagCount; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0)] // 如这里改为 SizeConst = 1 运行就不会出错 STAGINFOPARAM[] tagInfo; }; Int32 nSize2 = Marshal.SizeOf(typeof(SREADINVENTORYTAGINFORSPPARAM)); // 一运行到这里就出错? MessageBox.Show(nSize2.ToString());