2

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.

Tomas Kubes
  • 23,880
  • 18
  • 111
  • 148
TheDude
  • 257
  • 1
  • 9

1 Answers1

1

Looks like that this Exception is not related to the marshaling of the above structure directly.

Please take a look in your code for cross accessing to the same instance by another thread.

Guy P
  • 1,395
  • 17
  • 33