[Mono-bugs] [Bug 647267] New: Wrong Size of a Struct with Marshal Sizeof

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sun Oct 17 16:34:53 EDT 2010


https://bugzilla.novell.com/show_bug.cgi?id=647267

https://bugzilla.novell.com/show_bug.cgi?id=647267#c0


           Summary: Wrong Size of a Struct with Marshal Sizeof
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 1.2.0
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: CORLIB
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: jochen.kuehner at gmx.de
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US)
AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.472.63 Safari/534.3

i use the following struct:

        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
        private struct FieldDescriptor
        {
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 11)]
            public string fieldName;
            public char fieldType;  //turn this to byte, then it works
            public Int32 address;
            public byte fieldLen;
            public byte count;
            public Int16 reserved1;
            public byte workArea;
            public Int16 reserved2;
            public byte flag;
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 7)]
            public byte[] reserved3;
            public byte indexFlag;
        }
        #endregion

and this code to read it:
buffer = br.ReadBytes(Marshal.SizeOf(typeof(FieldDescriptor)));

with dotnet framework the buffer is 32 bytes, with mono it's 33!

when i turn the char to a byte, than it works!

Reproducible: Always

Steps to Reproduce:
1.
2.
3.

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list