我正在尝试Marshall一个包含整数,字符串和字符串数组的结构。我在序列化字符串数组时遇到问题。每次我收到“FatalExecutionEngine Error”。我需要序列化我的结构,以便使用套接字API通过TCP发送它。
我找到了几个例子,但我真的不理解它们:/任何人都可以解释一下这个过程是如何工作的?
[StructLayout(LayoutKind.Sequential)]
public struct MESSAGE
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 101)]
public string gameID;
public int msgID;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 101)]
public string param1;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 101)]
public string param2;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 101)]
public string param3;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 101)]
public string param4;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 101)]
public string param5;
[MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.LPTStr, SizeConst = 222)]
public string[] clientsArray;
}