[Mono-bugs] [Bug 444715] New: Mono throws an exception when passing a generic struct ( or class) to a PInvoke method

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Nov 13 11:54:02 EST 2008


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


           Summary: Mono throws an exception when passing a generic struct
                    (or class) to a PInvoke method
           Product: Mono: Runtime
           Version: SVN
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: generics
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: s-kiess at web.de
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


Mono throws an exception when passing a generic struct (or class) to a PInvoke
method.

---
using System.Runtime.InteropServices;

struct GenericStruct<T> { public int i; }

class GenericPInvokeParameter {
  [DllImport("Kernel32")]
  static extern int GetCurrentThreadId(GenericStruct<byte> arg);

  [DllImport ("libc.so.6")]
  static extern int getpid (GenericStruct<byte> arg);

  public static void Main () {
    //GetCurrentThreadId (new GenericStruct<byte>());
    getpid (new GenericStruct<byte>());
  }
}
---

This code is accepted by PEVerify and executed successfully by .NET.
Mono will throw an exception:

Unhandled Exception: System.InvalidProgramException: Invalid IL code in
(wrapper managed-to-native) GenericPInvokeParameter:getpid (GenericStruct`1):
IL_0008: calli     0x00000002


  at GenericPInvokeParameter.Main () [0x00000]


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