[Mono-bugs] [Bug 81659][Nor] New - Win32 Interop Issue

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Thu May 17 13:00:47 EDT 2007


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 monkey at jpobst.com.

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

--- shadow/81659	2007-05-17 13:00:47.000000000 -0400
+++ shadow/81659.tmp.28008	2007-05-17 13:00:47.000000000 -0400
@@ -0,0 +1,69 @@
+Bug#: 81659
+Product: Mono: Runtime
+Version: 1.1
+OS: 
+OS Details: Vista
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: interop
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: monkey at jpobst.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Win32 Interop Issue
+
+Description of Problem:
+The attached code generally fails on SetClipboardData, causing problems for
+MWF on Windows.  It does not fail on MS.Net 2.0 runtime.  My best guess is
+an interop bug.
+
+using System;
+using System.Runtime.InteropServices;
+
+public class HelloWorld
+{
+	static public void Main ()
+	{
+		//int CF_TEXT = 1;
+		int CF_UNICODETEXT = 13;
+		
+		Console.WriteLine ("open succeeded: {0}", OpenClipboard (IntPtr.Zero));
+		Console.WriteLine ("empty succeeded: {0}", EmptyClipboard ());
+
+		IntPtr hmem = Marshal.StringToHGlobalUni ("test");
+
+		Console.WriteLine ("hmem: {0}", hmem.ToString ());
+		Console.WriteLine ("set succeeded: {0} ({1})", SetClipboardData
+((uint)CF_UNICODETEXT, hmem) != IntPtr.Zero, GetLastError ());
+		Console.WriteLine ("close succeeded: {0}", CloseClipboard ());
+	}
+	
+	[DllImport ("user32.dll")]
+	private extern static IntPtr SetClipboardData (uint format, IntPtr handle);
+	[DllImport ("user32.dll")]
+	private extern static bool OpenClipboard (IntPtr hwnd);
+	[DllImport ("user32.dll")]
+	private extern static bool CloseClipboard ();
+	[DllImport ("user32.dll")]
+	private extern static bool EmptyClipboard ();
+	[DllImport ("kernel32.dll")]
+	private extern static uint GetLastError ();
+}
+
+Actual Results (win/mono 1.2.4, 1.1 and 2.0 profile):
+open succeeded: True
+empty succeeded: True
+hmem: 19459576
+set succeeded: False (0)
+close succeeded: True
+
+Expected Results (.net 2.0):
+open succeeded: True
+empty succeeded: True
+hmem: 2142512
+set succeeded: True (0)
+close succeeded: True


More information about the mono-bugs mailing list