[Mono-winforms-list] Copy Paste is crashing the application

Alexander Reiter r.alex at tele2.at
Thu Sep 7 15:45:54 EDT 2006


Hi all,

I was playing around with Windows.Forms and found there a problem with the Copy Paste function. I've created two
textboxes. When I copy the text from the first textbox with CTRL+C and select then the second textbox and paste
the text with CRTL+V - the whole application is crashing. Attached to this text is the error code and a test application
where it's quite easy to demonstrate the problem. Maybe it's just a problem on my computer but it would be great if
someone could try to Copy/Paste in maybe self created applications and give a short comment -- so than I would know
that the problem is on my machine - or did I miss something from code point of view ? Thanks in advance.

/alex

The error code:
---
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object
  at System.Windows.Forms.XplatUIX11.UpdateMessageQueue (System.Windows.Forms.XEventQueue queue) [0x00090] in /tmp/scratch/BUILD/mono-1.1.17.1/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs:1169 
  at System.Windows.Forms.XplatUIX11.ClipboardAvailableFormats (IntPtr handle) [0x0007b] in /tmp/scratch/BUILD/mono-1.1.17.1/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs:2000 
  at System.Windows.Forms.XplatUI.ClipboardAvailableFormats (IntPtr handle) [0x00000] in /tmp/scratch/BUILD/mono-1.1.17.1/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUI.cs:352 
  at System.Windows.Forms.Clipboard.GetDataObject () [0x00014] in /tmp/scratch/BUILD/mono-1.1.17.1/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Clipboard.cs:71 
  at System.Windows.Forms.TextBoxBase.Paste (System.Windows.Forms.Format format, Boolean obey_length) [0x00000] in /tmp/scratch/BUILD/mono-1.1.17.1/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs:1766 
  at System.Windows.Forms.TextBoxBase.ProcessKey (Keys keyData) [0x000e0] in /tmp/scratch/BUILD/mono-1.1.17.1/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs:861 
  at System.Windows.Forms.TextBoxBase.WndProc (System.Windows.Forms.Message m) [0x00025] in /tmp/scratch/BUILD/mono-1.1.17.1/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs:1205 
  at System.Windows.Forms.TextBox.WndProc (System.Windows.Forms.Message m) [0x00000] in /tmp/scratch/BUILD/mono-1.1.17.1/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBox.cs:264 
  at System.Windows.Forms.Control+ControlNativeWindow.WndProc (System.Windows.Forms.Message m) [0x00000] in /tmp/scratch/BUILD/mono-1.1.17.1/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:162 
  at System.Windows.Forms.NativeWindow.WndProc (IntPtr hWnd, Msg msg, IntPtr wParam, IntPtr lParam) [0x00053] in /tmp/scratch/BUILD/mono-1.1.17.1/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NativeWindow.cs:145 
  at System.Windows.Forms.XplatUIX11.DispatchMessage (System.Windows.Forms.MSG msg) [0x00000] in /tmp/scratch/BUILD/mono-1.1.17.1/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs:2701 
  at System.Windows.Forms.XplatUI.DispatchMessage (System.Windows.Forms.MSG msg) [0x00000] in /tmp/scratch/BUILD/mono-1.1.17.1/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUI.cs:427 
  at System.Windows.Forms.Application.RunLoop (Boolean Modal, System.Windows.Forms.ApplicationContext context) [0x0023c] in /tmp/scratch/BUILD/mono-1.1.17.1/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Application.cs:521 
  at System.Windows.Forms.Application.Run (System.Windows.Forms.Form mainForm) [0x00000] in /tmp/scratch/BUILD/mono-1.1.17.1/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Application.cs:415 
  at CopyPaste.MainClass.Main (System.String[] args) [0x00000] in /home/alex/Data/csharp/CopyPaste/CopyPaste.cs:13 
----

-- file CopyPaste.cs
// created on 07.09.2006 at 21:05
using System;
using System.Drawing;
using System.Windows.Forms;

namespace CopyPaste
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			// Console.WriteLine("Hello World!");
			Application.Run(new MainForm());
		}
	}
}

-- file MainForms.cs
// created on 07.09.2006 at 21:09
using System;
using System.Drawing;
using System.Windows.Forms;

namespace CopyPaste
{
    public partial class MainForm : System.Windows.Forms.Form
    {
		
	private System.ComponentModel.IContainer components;
    	private System.Windows.Forms.TextBox tbox_Copy;
    	private System.Windows.Forms.TextBox tbox_Paste;
    	
    	
	//------------------------------------------------------------------------------------------        
        public MainForm()
        {
            this.SuspendLayout();
                        
            // set the window size
            this.Height = 100;
            this.Width = 400;
        
            //InitializeComponent();
            this.components = new System.ComponentModel.Container();
            this.tbox_Copy = new System.Windows.Forms.TextBox();
            this.tbox_Paste = new System.Windows.Forms.TextBox();
            
            //
            //tbox_Copy
            //
            this.tbox_Copy.Location = new System.Drawing.Point(12, 15);
            this.tbox_Copy.Name = "tbox_Copy";
            this.tbox_Copy.Size = new System.Drawing.Size(350, 20);
            this.tbox_Copy.TabIndex = 0;
            this.tbox_Copy.Text = this.tbox_Copy.Name;
            
            //
            //tbox_Paste
            //
            this.tbox_Paste.Location = new System.Drawing.Point(12, this.tbox_Copy.Location.Y + 
            														this.tbox_Copy.Height + 15);
            this.tbox_Paste.Name = "tbox_Paste";
            this.tbox_Paste.Size = new System.Drawing.Size(350, 20);
            this.tbox_Paste.TabIndex = 1;
            this.tbox_Paste.Text = this.tbox_Paste.Name;
            
            this.Controls.Add(this.tbox_Copy);
            this.Controls.Add(this.tbox_Paste);
            this.ResumeLayout();
        }
    }
 }


More information about the Mono-winforms-list mailing list