[Mono-bugs] [Bug 76123][Min] New - Marshal.StringToHGlobalUni() fails to store correct string

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Fri Sep 16 13:13:08 EDT 2005


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 atsushi at ximian.com.

http://bugzilla.ximian.com/show_bug.cgi?id=76123

--- shadow/76123	2005-09-16 13:13:08.000000000 -0400
+++ shadow/76123.tmp.25580	2005-09-16 13:13:08.000000000 -0400
@@ -0,0 +1,64 @@
+Bug#: 76123
+Product: Mono: Runtime
+Version: 1.1
+OS: 
+OS Details: Windows XP Professional SP2
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Minor
+Component: interop
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: atsushi at ximian.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Marshal.StringToHGlobalUni() fails to store correct string
+
+The example code below shows unexpected marshaling results.
+
+using System;
+using System.Runtime.InteropServices;
+
+public class Test
+{
+        public static void Main (string [] args)
+        {
+                if (args.Length > 0)
+                        Console.WriteLine (args [0].Length);
+                IntPtr handle = Marshal.StringToHGlobalUni ("unicode data");
+                string s = Marshal.PtrToStringUni (handle);
+                Console.WriteLine ("{0} {1}", s.Length, s);
+
+                handle = Marshal.StringToHGlobalUni ("unicode data string");
+                s = Marshal.PtrToStringUni (handle);
+                Console.WriteLine ("{0} {1}", s.Length, s);
+        }
+}
+
+
+Actual Results:
+It looks depending on what string I pass the code (it is nothing to do what
+that code prints).
+
+$ mono marshal.exe
+24 unicode data???????????
+19 unicode data string
+
+Expected Results:
+12 unicode data
+19 unicode data string
+
+How often does this happen? 
+It consistently happens on my box.
+
+Additional Information:
+I have glib2.6.6 installed from tml's Gimp for Win32 page (
+http://www.gimp.org/~tml/gimp/win32/ ) to be used with mono. I also tried
+2.6.3 and 2.4.7 (from his older pages as well) and got the same results.
+
+It affects on MWF Clipboard behavior on Win32.
+
+jonp also tried the code but could not reproduce it (however he said that
+he does not have the latest code from svn).


More information about the mono-bugs mailing list