[Mono-bugs] [Bug 655674] Got exception and program crashes when LayoutKind.Auto is used during P/Invoke

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Dec 1 08:16:07 EST 2010


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

https://bugzilla.novell.com/show_bug.cgi?id=655674#c2


Zoltan Varga <vargaz at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |vargaz at gmail.com

--- Comment #2 from Zoltan Varga <vargaz at gmail.com> 2010-12-01 13:16:06 UTC ---
On net 4.0, I get:

Unhandled Exception: System.ArgumentException: The specified structure must be
blittable or have layout information.
Parameter name: structure
   at System.Runtime.InteropServices.Marshal.StructureToPtr(Object structure,
IntPtr ptr, Boolean fDeleteOld)
   at Program.Main(String[] args)

for this testcase:
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
using System;
using System.Runtime.InteropServices;

    [StructLayout (LayoutKind.Auto)]
    public class SimpleClass {
    }

class Program
{
    static void Main (string[] args)
    {
        SimpleClass c = new SimpleClass ();
        IntPtr p = Marshal.AllocHGlobal (1024);
        Marshal.StructureToPtr (c, p, false);
    }
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

-- 
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