[Mono-bugs] [Bug 76326][Nor] Changed - Sometimes Windows Forms get
a Null Reference Exception
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Wed Oct 5 15:39:10 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 carlos at applianz.com.
http://bugzilla.ximian.com/show_bug.cgi?id=76326
--- shadow/76326 2005-10-05 15:16:57.000000000 -0400
+++ shadow/76326.tmp.4835 2005-10-05 15:39:10.000000000 -0400
@@ -233,6 +233,201 @@
------- Additional Comments From carlos at applianz.com 2005-10-05 15:16 -------
I thought about that so I commented out the line that does:
this.listBox1.Items.Add("test");
and the problem still ocurred, however it seemed to happen less often,
I don't know if that helps.
Thanks for the links though.
+
+------- Additional Comments From carlos at applianz.com 2005-10-05 15:39 -------
+Ok I changed the example to use Invoke, and it works on Windows. On
+Linux I still get the exception I was getting before but just like
+before every so often it actually runs, at which point I get a
+different exception, should I submit that as a different bug? Its
+probably related to my method taking two params and me not passing any
+but on Windows it doesnt throw an exception.
+
+I am copying the new exception followed by the code.
+=================================
+mono Test.exe
+Mono System.Windows.Forms Assembly [Revision: 49925; built: 2005/9/11
+14:27:24]
+Keyboard: United States keyboard layout (phantom key version)
+Creating caret
+Destroying caret
+Creating caret
+
+Unhandled Exception: System.Reflection.TargetParameterCountException:
+Number of parameter does not match expected count.
+in <0x00064> System.Reflection.Binder:ConvertArgs
+(System.Reflection.Binder binder, System.Object[] args,
+System.Reflection.ParameterInfo[] pinfo,
+System.Globalization.CultureInfo culture)
+in <0x00084> System.Reflection.MonoMethod:Invoke (System.Object obj,
+BindingFlags invokeAttr, System.Reflection.Binder binder,
+System.Object[] parameters, System.Globalization.CultureInfo culture)
+in <0x00034> System.Reflection.MethodBase:Invoke (System.Object obj,
+System.Object[] parameters)
+in <0x000d9> System.Delegate:DynamicInvokeImpl (System.Object[] args)
+in <0x00031> System.MulticastDelegate:DynamicInvokeImpl
+(System.Object[] args)
+in <0x00020> System.Delegate:DynamicInvoke (System.Object[] args)
+in <0x00100>
+System.Windows.Forms.XplatUIDriverSupport:ExecuteClientMessage
+(GCHandle gchandle)
+in <0x011b6> System.Windows.Forms.XplatUIX11:GetMessage
+(System.Windows.Forms.MSG msg, IntPtr handle, Int32 wFilterMin, Int32
+wFilterMax)
+in <0x00040> System.Windows.Forms.XplatUI:GetMessage
+(System.Windows.Forms.MSG msg, IntPtr hWnd, Int32 wFilterMin, Int32
+wFilterMax)
+in <0x0032e> System.Windows.Forms.Application:Run ()
+in <0x000e7> System.Windows.Forms.Application:Run
+(System.Windows.Forms.ApplicationContext context)
+in <0x00036> System.Windows.Forms.Application:Run
+(System.Windows.Forms.Form mainForm)
+in <0x0009b> Test.Form1:Main ()
+====================================================
+
+Here is the code:
+
+using System;
+using System.Drawing;
+using System.Collections;
+using System.ComponentModel;
+using System.Windows.Forms;
+using System.Data;
+
+namespace Test
+{
+ /// <summary>
+ /// Summary description for Form1.
+ /// </summary>
+ public class Form1 : System.Windows.Forms.Form
+ {
+ private System.Windows.Forms.TextBox textBox1;
+ private System.Windows.Forms.ListBox listBox1;
+ private System.Windows.Forms.Button button1;
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.Container components = null;
+
+ public Form1()
+ {
+ //
+ // Required for Windows Form Designer support
+ //
+ InitializeComponent();
+
+ //
+ // TODO: Add any constructor code after InitializeComponent call
+ //
+ }
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ protected override void Dispose( bool disposing )
+ {
+ if( disposing )
+ {
+ if (components != null)
+ {
+ components.Dispose();
+ }
+ }
+ base.Dispose( disposing );
+ }
+
+ #region Windows Form Designer generated code
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.textBox1 = new System.Windows.Forms.TextBox();
+ this.listBox1 = new System.Windows.Forms.ListBox();
+ this.button1 = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // textBox1
+ //
+ this.textBox1.Location = new System.Drawing.Point(40, 40);
+ this.textBox1.Name = "textBox1";
+ this.textBox1.Size = new System.Drawing.Size(88, 20);
+ this.textBox1.TabIndex = 0;
+ this.textBox1.Text = "textBox1";
+ //
+ // listBox1
+ //
+ this.listBox1.Location = new System.Drawing.Point(32, 88);
+ this.listBox1.Name = "listBox1";
+ this.listBox1.Size = new System.Drawing.Size(88, 95);
+ this.listBox1.TabIndex = 1;
+ //
+ // button1
+ //
+ this.button1.Location = new System.Drawing.Point(184, 176);
+ this.button1.Name = "button1";
+ this.button1.Size = new System.Drawing.Size(88, 64);
+ this.button1.TabIndex = 2;
+ this.button1.Text = "button1";
+ //
+ // Form1
+ //
+ this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
+ this.ClientSize = new System.Drawing.Size(292, 273);
+ this.Controls.Add(this.button1);
+ this.Controls.Add(this.listBox1);
+ this.Controls.Add(this.textBox1);
+ this.Name = "Form1";
+ this.Text = "Form1";
+ this.Load += new System.EventHandler(this.Form1_Load);
+ this.ResumeLayout(false);
+
+ }
+ #endregion
+
+ /// <summary>
+ /// The main entry point for the application.
+ /// </summary>
+ [STAThread]
+ static void Main()
+ {
+ Form1 f = new Form1();
+ System.Threading.Thread thread = new System.Threading.Thread(new
+System.Threading.ThreadStart(f.Start));
+ thread.IsBackground = true;
+ thread.Start();
+ Application.Run(f);
+ }
+
+ private void Form1_Load(object sender, System.EventArgs e)
+ {
+
+ }
+ private void Start()
+ {
+ while(true)
+ {
+ // this.listBox1.Items.Add("test");
+ try
+ {
+ System.Threading.Thread.Sleep(10000);
+ this.listBox1.Invoke(new EventHandler(Test));
+
+ }
+ catch(Exception ex)
+ {
+ Console.WriteLine(ex);
+ }
+
+ }
+ }
+ private void Test(Object sender, System.EventArgs ev)
+ {
+ this.listBox1.Items.Add("test");
+ }
+ }
+}
+
More information about the mono-bugs
mailing list