[Mono-bugs] [Bug 363353] New: VS Designer generated TreeView code causes Mono exception

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Feb 20 12:43:34 EST 2008


https://bugzilla.novell.com/show_bug.cgi?id=363353


           Summary: VS Designer generated TreeView code causes Mono
                    exception
           Product: Mono: Class Libraries
           Version: 1.2.6
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Windows.Forms
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: derekd at omni-ts.com
         QAContact: mono-bugs at lists.ximian.com
                CC: stephane at omni-ts.com
          Found By: ---


VS Designer assigns TreeNodes to TreeView.Nodes before assigning the image list
to StateImageList for the TreeView. This causes Mono to throw an exception:

Unhandled Exception: System.NullReferenceException: Object reference not set to
an instance of an object
  at System.Windows.Forms.TreeNode.get_StateImage () [0x00000] 
  at System.Windows.Forms.TreeNode.GetX () [0x00000] 
  at System.Windows.Forms.TreeNode.get_Bounds () [0x00000] 
  at (wrapper remoting-invoke-with-check)
System.Windows.Forms.TreeNode:get_Bounds ()
  at System.Windows.Forms.TreeView.UpdateNode (System.Windows.Forms.TreeNode
node) [0x00000] 
  at (wrapper remoting-invoke-with-check)
System.Windows.Forms.TreeView:UpdateNode (System.Windows.Forms.TreeNode)
  at System.Windows.Forms.TreeNodeCollection.SetupNode
(System.Windows.Forms.TreeNode node) [0x00000] 
  at System.Windows.Forms.TreeNodeCollection.Add (System.Windows.Forms.TreeNode
node) [0x00000] 
  at System.Windows.Forms.TreeNodeCollection.AddRange
(System.Windows.Forms.TreeNode[] nodes) [0x00000] 
  at TreeViewTest.Form1.InitializeComponent () [0x00000] 
  at TreeViewTest.Form1..ctor () [0x00000] 


You can fix this by manually moving the StateImageList assignment to above the
lines that AddRange the TreeNodes to TreeViewNodes:

Example before:
            treeNode4.StateImageIndex = 0;
            treeNode4.Text = "Node2";
            this.treeView1.Nodes.AddRange(new System.Windows.Forms.TreeNode[] {
            treeNode1,
            treeNode3,
            treeNode4});
            this.treeView1.SelectedImageIndex = 0;
            this.treeView1.Size = new System.Drawing.Size(248, 222);
            this.treeView1.StateImageList = this.imageList2;
            this.treeView1.TabIndex = 0;

Example after:
            treeNode4.StateImageIndex = 0;
            treeNode4.Text = "Node2";
            this.treeView1.StateImageList = this.imageList2;
            this.treeView1.Nodes.AddRange(new System.Windows.Forms.TreeNode[] {
            treeNode1,
            treeNode3,
            treeNode4});
            this.treeView1.SelectedImageIndex = 0;
            this.treeView1.Size = new System.Drawing.Size(248, 222);
            this.treeView1.TabIndex = 0;


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list