[Mono-bugs] [Bug 76161][Maj] New - Handles for control containers are created too early.

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Tue Sep 20 02:53:23 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 miguel at ximian.com.

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

--- shadow/76161	2005-09-20 02:53:23.000000000 -0400
+++ shadow/76161.tmp.17312	2005-09-20 02:53:23.000000000 -0400
@@ -0,0 +1,65 @@
+Bug#: 76161
+Product: Mono: Class Libraries
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Major
+Component: Windows.Forms
+AssignedTo: peter at novonyx.com                            
+ReportedBy: miguel at ximian.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Handles for control containers are created too early.
+
+The following program should not print anything, instead it throws an
+exception.
+
+This is a reduced version of a more complex case which is making a popular
+Windows application crash on Mono as it never initializes completely before
+the handle is created.
+
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+
+        class SearchBar : UserControl {
+                TextBox filterTextBox;
+                bool ready = false;
+
+                public SearchBar()
+                {
+                        this.filterTextBox = new TextBox();
+                        this.filterTextBox.TabIndex = 1;
+                        this.filterTextBox.Dock = DockStyle.Fill;
+                        this.Controls.Add(this.filterTextBox);
+                        ready = true;
+                }
+
+                protected override void OnHandleCreated(EventArgs e)
+                {
+                        base.OnHandleCreated(e);
+
+                        if (!ready){
+                                throw new Exception ("The handle is created
+before we are ready!");
+                        }
+                }
+        }
+
+        class MainWindow : System.Windows.Forms.Form {
+                public MainWindow() {
+                        SearchBar b = new SearchBar ();
+                        ClientSize = new System.Drawing.Size (250, 250);
+                        b.Dock = DockStyle.Fill;
+                        this.Controls.Add(b);
+                }
+
+                public static void Main(string[] args) {
+                        Application.Run(new MainWindow());
+                }
+        }


More information about the mono-bugs mailing list