[Mono-dev] Re: StructLayout with misaligned offsets
tcmichals
tcmichals at msn.com
Wed Apr 12 14:52:24 EDT 2006
Also found this information, removing the MarshalAs and use discrete
variables works, ie
// public ushort Avg0;
// [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)]
//public ushort[] Avg;
public ushort Avg0;public ushort Avg1;public ushort Avg2;public ushort
Avg3;public ushort Avg4;public ushort Avg5;public ushort Avg6;
public ushort Avg7;public ushort Avg8;public ushort Avg9;public ushort
Avg10;public ushort Avg11;
also,
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi),
Serializable]
public struct byteD
{
ushort Lo, Hi;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
byte[] Comment;
};
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet =
CharSet.Ansi), Serializable]
public struct charD
{
ushort Lo, Hi;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
char [] Comment;
};
Console.WriteLine("byteD " + Marshal.SizeOf(typeof(byteD)).ToString() +
" charD " + Marshal.SizeOf(typeof(charD)).ToString());
Ouputs on .NET 2.0
Hello World
byteD 36 charD 36
On 1.1.14
Hello World
byteD 36 charD 68
"Zoltan Varga" <vargaz at gmail.com> wrote in message
news:295e750a0604120928reebc06eh1e00f61496fb8123 at mail.gmail.com...
Hi,
This is a known bug and it is tracked as:
http://bugzilla.ximian.com/show_bug.cgi?id=77788
Zoltan
More information about the Mono-devel-list
mailing list