Thing is the exact same structure works fine if LayoutKind.Sequential is used. For example (pardon the VB):
Code:
<StructLayout(LayoutKind.Explicit, Pack:=1, CharSet:=CharSet.Ansi)> _
Public Structure SOMESTRUCT
<FieldOffset(0), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=10) Public somestring As String
<FieldOffset(10), MarshalAs(UnmanagedType.ByValArray, SizeConst:=10) Public somearray() As Integer
...
End Structure
Throws the mentioned exception. However, if you change it to LayoutKind.Sequential, it's more than happy. Hence... my confusion.
Anyway, it appears that I've sort of worked around this issue by making somearray() into its own structure (it's actually a union on the C-side with another member) defined as LayoutKind.Explicit, since it's at the beginning of the structure alignment doesn't matter much. And SOMESTRUCT is set as LayoutKind.Sequential with Pack:=1 and the second member as a type of the structure that hosts somearray(). It's not pretty, but it seems to work. I'm just trying to make sure the marshaler is happy with what's going on here.
To be fair, the .Net side of things really isn't MY problem, I'm just trying to help someone out, as well as make sure that the interop with my native library works.