I\'m trying to integrate Video4Linux in my managed application. Indeed I\'ve declared all required structures and relative ioctl. In this question I present two i
The problem has been solved by forcing the structure size to the actual one (204, in my case), and remove the array field RawData
(as suggested by David Heffernan).
Indeed:
[StructLayout(LayoutKind.Explicit, Pack = 4, CharSet = CharSet.Ansi, Size = 204)]
public struct Format
{
public Format(BufferType bufferType)
{
Type = bufferType;
Pixmap = new PixmapFormat();
}
public Format(BufferType bufferType, PixmapFormat pixmapFormat)
{
Type = bufferType;
Pixmap = pixmapFormat;
}
[FieldOffset(0)]
public BufferType Type;
[FieldOffset(4)]
public PixmapFormat Pixmap;
}
Of course, Marshal.SizeOf(typeof(Format)) == 204
.