I am trying to convert a byte[] to a struct that contains an array of a struct that contains an array.
Something like this:
[StructLayout(LayoutKind.Sequential, Pack = 4)]
public struct Util_VersionType
{
[MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.LPStr, SizeConst = 5000)]
public DataItemsString[] Data;
}
[StructLayout(LayoutKind.Sequential, Pack = 4)]
public struct DataItemsString {
[MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.U1, SizeConst = 10)]
public System.Byte[] Value;
public System.UInt32 Validity;
}
I use Marshal.PtrToStructure
Sometimes there is no problem but in about 100 attempts the CLR throws an uncatchable ExecutionEngineException.
Please help. I'm lost.