[Mono-bugs] [Bug 76510][Nor] New - Wrong MenuItem index in a menu causes a System.ArguementException on MS.NET but not MWF

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Sat Oct 22 08:12:40 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 xenomorph2 at onlinehome.de.

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

--- shadow/76510	2005-10-22 08:12:40.000000000 -0400
+++ shadow/76510.tmp.13802	2005-10-22 08:12:40.000000000 -0400
@@ -0,0 +1,87 @@
+Bug#: 76510
+Product: Mono: Class Libraries
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Windows.Forms
+AssignedTo: peter at novonyx.com                            
+ReportedBy: xenomorph2 at onlinehome.de               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Wrong MenuItem index in a menu causes a System.ArguementException on MS.NET but not MWF
+
+If the index values in a menu are not correct, that means if for example
+one menuitem is missing, MS.NET stops execution with a
+System.ArguementException.
+MWF doesn't stop.
+
+The following sample stops on MS.NET but works on MWF:
+
+using System;
+using System.Windows.Forms;
+
+namespace MenuError
+{
+	public class MyForm : Form
+	{
+		private MainMenu mainMenu;
+		private MenuItem menuItemFile;
+		private MenuItem menuItem2;
+		private MenuItem menuItem3;
+		private MenuItem menuItem4;
+		private MenuItem menuItem5;
+		private MenuItem menuItemDash;
+		
+		public MyForm()
+		{
+			mainMenu = new MainMenu();
+			
+			menuItemFile = new MenuItem();
+			menuItem2 = new MenuItem();
+			menuItem3 = new MenuItem();
+			menuItem4 = new MenuItem();
+			menuItem5 = new MenuItem();
+			menuItemDash = new MenuItem();
+			
+			menuItemFile.Index = 0;
+			// menuItemDash is not added, that should cause
+			// an System.ArguementException during runtime
+			// because index 3 is missing in this example
+			menuItemFile.MenuItems.AddRange(new MenuItem[] {
+							menuItem2,
+							menuItem3,
+							menuItem4,
+							menuItem5 });
+			menuItemFile.Text = "&File";
+			
+			menuItem2.Index = 0;
+			menuItem2.Text = "menuitem 1";
+			
+			menuItem3.Index = 1;
+			menuItem3.Text = "menuitem 2";
+			
+			menuItem4.Index = 2;
+			menuItem4.Text = "menuitem 3";
+			
+			menuItemDash.Index = 3;
+			menuItemDash.Text = "-";
+			
+			menuItem5.Index = 4;
+			menuItem5.Text = "menuitem 4";
+			
+			mainMenu.MenuItems.AddRange(new MenuItem[] {menuItemFile});
+		}
+		
+		[STAThread]
+		static void Main()
+		{
+			Application.Run(new MyForm());
+		}
+	}
+}


More information about the mono-bugs mailing list