[Mono-bugs] [Bug 36509][Nor] New - wrong marshalling attributes
bugzilla-daemon@rocky.ximian.com
bugzilla-daemon@rocky.ximian.com
Thu, 9 Jan 2003 05:47:30 -0500 (EST)
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by dietmar@ximian.com.
http://bugzilla.ximian.com/show_bug.cgi?id=36509
--- shadow/36509 Thu Jan 9 05:47:30 2003
+++ shadow/36509.tmp.22543 Thu Jan 9 05:47:30 2003
@@ -0,0 +1,56 @@
+Bug#: 36509
+Product: Mono/MCS
+Version: unspecified
+OS: other
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: Misc
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: dietmar@ximian.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: wrong marshalling attributes
+
+mcs does not encode the specified marshalling attribute:
+
+------------------------------------
+using System.Runtime.InteropServices;
+
+public class Test {
+
+ [DllImport("libtest.so")]
+ private static extern void myFunction(
+ [MarshalAs(UnmanagedType.LPWStr)] string s,
+ int length );
+
+
+ public static int Main () {
+
+
+ string s = "ABC";
+
+ Console.WriteLine( s.Length );
+ myFunction( s, s.Length );
+
+ return 0;
+ }
+}
+-----------------------
+
+compile with mcs, and then run:
+
+>monodis --marshal pinvoke.exe
+FieldMarshal Table (1..1)
+1: (0x0005) Param 2: unknown
+
+
+when compiled with csc it get the correct result:
+
+>monodis --marshal pinvoke.exe
+FieldMarshal Table (1..1)
+1: (0x0003) Param 1: lpwstr