Hello all,
I have come across a strange problem, i am using a 3rd part C++ DLL which requires some structures to be passed, and updates the structures for me. There seems to be a difference when i run the application on a pocketPC or on win32. The size of some structures change depending on which system they are running.
I narrowed it down to the following. The names and size of the structures have been cutdown and changed to protect the innocent.
[
StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] internal unsafe struct yetAnotherStruct{
public int Number; public fixed int Numbers[32];}
[
StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] internal struct ICanSizeMe{
[
MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] public string text; public yetAnotherStruct structo;}
When you now run this code on a PPC
MessageBox.Show(Marshal.SizeOf(typeof(ICanSizeMe)).ToString())
It will report a size of 264 bytes (which is incorrect), running the same exe on Win32 will give a size of 388 bytes (correct).
its a Unicode string of 128 chars (128*2)=256
+ The size of yetAnotherStruct(1 int=4 + array of 32 ints=128 bytes)
so 4+128+256=388
It seems like its not inlining the Numbers property of the yetAnotherStruct on CF, but it's inlining it in the Full Framework. without changing the executable.
is this a possible problem with CF, or am i doing something wrong.