Microsoft Knowledge Base Email Alertz

KBAlertz.com: (890328) - Fixes a problem where you receive a NullReferenceException exception when you merge parent and child menus in MDI form-based applications in the .NET Framework 1.1.

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]

Search KbAlertz

Advanced Search

Webmasters
Put kbAlertz on your website.
[ Click Here for more! ]





ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
The ad says 3 - but KBAlertz referrals get
** SIX MONTHS FREE **


Bug Tracking Software
For bug tracking software or defect tracking software or issue tracking software, visit Axosoft.


Community Site



We Send hundreds of thousands of emails using ASP.NET Email



Expert Web Design & Graphic Design
Design44.com

ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
The ad says 3 - but KBAlertz referrals get
** SIX MONTHS FREE **




Mentioned In








Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks




Article ID: 890328 - Last Review: December 27, 2006 - Revision: 3.1

FIX: You receive a "System.NullReferenceException" exception when you merge parent and child menus in an MDI form-based application in the .NET Framework 1.1

Notice

For users who have the Microsoft .NET Framework 1.1 Service Pack 1 installed

This article discusses the same problem that is discussed in Microsoft Knowledge Base (KB) article 895579. However, the hotfix that this article discusses is only for the original release version of the .NET Framework 1.1. If you have the .NET Framework 1.1 Service Pack 1 (SP1) installed, use the hotfix that is discussed in KB article 895579. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
895579  (http://kbalertz.com/Feedback.aspx?kbNumber=895579/ ) FIX: You receive a "System.NullReferenceException" exception when you merge parent menus and child menus in an MDI form-based application in the .NET Framework 1.1 Service Pack 1

On This Page

SYMPTOMS

In the Microsoft .NET Framework 1.1, when you merge parent and child menus, a runtime error may occur and you may receive an exception error message that resembles the following:
System.NullReferenceException: Object reference not set to an instance of an object.
Note You may merge parent and child menus in a Multiple Document Interface (MDI) form-based application.

RESOLUTION

Hotfix information

A supported hotfix is now available from Microsoft. However, it is intended to correct only the problem that is described in this article. Apply it only to systems that are experiencing this specific problem. This hotfix may receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next .NET Framework 1.1 service pack that contains this hotfix.

To resolve this problem immediately, contact Microsoft Customer Support Services to obtain the hotfix. For a complete list of Microsoft Customer Support Services telephone numbers and information about support costs, visit the following Microsoft Web site:
http://support.microsoft.com/contactus/?ws=support (http://support.microsoft.com/contactus/?ws=support)
Note In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question.

File information

The English version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in Coordinated Universal Time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time item in Control Panel.
  Date         Time   Version        Size       File name
  ----------------------------------------------------------------------
  01-Dec-2004  04:08  1.1.4322.1090  1,703,936  System.Design.dll
  01-Dec-2004  04:04  1.1.4322.1090    466,944  System.Drawing.dll
  01-Dec-2004  04:13  1.1.4322.1090  2,048,000  System.Windows.Forms.dll

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

MORE INFORMATION

Steps to reproduce the problem

  1. Start Microsoft Visual Studio .NET 2003.
  2. On the File menu, click New, and then click Project.
  3. Click Visual C# Projects, click Windows Application, and then click OK.
  4. In Solution Explorer, right-click Form1.cs, click View Code, and then replace all the code that is in Form1.cs with the following code.
    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;
    
    namespace MDIMenuTest
    {
    	/// <summary>
    	/// Summary description for Form1.
    	/// </summary>
    	public class Form1 : System.Windows.Forms.Form
    	{
    		private System.Windows.Forms.MainMenu mainMenu1;
    		private System.Windows.Forms.MenuItem menuMain;
    		private System.Windows.Forms.MenuItem MenuFromMain;
    		/// <summary>
    		/// Required designer variable.
    		/// </summary>
    		private System.ComponentModel.Container components = null;
    
    		public Form1()
    		{
    			//
    			// Required for Windows Form Designer support
    			//
    			InitializeComponent();
    
    			// create new child
    			Child formChild = new Child();
    			formChild.MdiParent = this;   // set parent
    			formChild.Show();          // display child
    		}
    
    		/// <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.mainMenu1 = new System.Windows.Forms.MainMenu();
    			this.menuMain = new System.Windows.Forms.MenuItem();
    			this.MenuFromMain = new System.Windows.Forms.MenuItem();
    			// 
    			// mainMenu1
    			// 
    			this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
    																					  this.menuMain});
    			// 
    			// menuMain
    			// 
    			this.menuMain.Index = 0;
    			this.menuMain.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
    																					 this.MenuFromMain});
    			this.menuMain.MergeType = System.Windows.Forms.MenuMerge.MergeItems;
    			this.menuMain.Text = "Menu";
    			// 
    			// MenuFromMain
    			// 
    			this.MenuFromMain.Index = 0;
    			this.MenuFromMain.Text = "MenuFromMain";
    			// 
    			// Form1
    			// 
    			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
    			this.ClientSize = new System.Drawing.Size(292, 266);
    			this.IsMdiContainer = true;
    			this.Menu = this.mainMenu1;
    			this.Name = "Form1";
    			this.Text = "Form1";
    			this.Load += new System.EventHandler(this.Form1_Load);
    
    		}
    		#endregion
    
    		/// <summary>
    		/// The main entry point for the application.
    		/// </summary>
    		[STAThread]
    		static void Main() 
    		{
    			Application.Run(new Form1());
    		}
    
    		
    	}
    }
    
  5. On the Project menu, click Add Windows Form, click Windows Form under Templates, name the form Child.cs, and then click Open.
  6. In Solution Explorer, right-click Child.cs, click View Code, and then replace all the code that is in Child.cs with the following code.
    using System;
    
    using System.Drawing;
    
    using System.Collections;
    
    using System.ComponentModel;
    
    using System.Windows.Forms;
    
    using System.Diagnostics;
    
     
    
    namespace MDIMenuTest
    
    {
    
    	/// <summary>
    
    	/// Summary description for Child.
    
    	/// </summary>
    
    	public class Child : System.Windows.Forms.Form
    
    	{
    
    		private System.Windows.Forms.MainMenu mainMenu1;
    
    		private System.Windows.Forms.MenuItem menuMain;
    
    		private System.Windows.Forms.MenuItem MenuFromChild;
    
    		private System.Windows.Forms.MenuItem menuItem1;
    
    		/// <summary>
    
    		/// Required designer variable.
    
    		/// </summary>
    
    		private System.ComponentModel.Container components = null;
    
     
    
    		public Child()
    
    		{
    
    			//
    
    			// 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.mainMenu1 = new System.Windows.Forms.MainMenu();
    
    			this.menuMain = new System.Windows.Forms.MenuItem();
    
    			this.MenuFromChild = new System.Windows.Forms.MenuItem();
    
    			// 
    
    			// mainMenu1
    
    			// 
    
    			this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
    
    																					  this.menuMain});
    
    			// 
    
    			// menuMain
    
    			// 
    
    			this.menuMain.Index = 0;
    
    			this.menuMain.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
    
    																					 this.MenuFromChild,
    
    			});
    
    			this.menuMain.MergeType = System.Windows.Forms.MenuMerge.MergeItems;
    
    			this.menuMain.Text = "Menu";
    
    			this.menuMain.Popup += new System.EventHandler(this.menuMain_Popup);
    
    			// 
    
    			// MenuFromChild
    
    			// 
    
    			this.MenuFromChild.Index = 0;
    
    			this.MenuFromChild.Text = "MenuFromChild";
    
     
    
    			// 
    
    			// Child
    
    			// 
    
    			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
    
    			this.ClientSize = new System.Drawing.Size(292, 266);
    
    			this.Menu = this.mainMenu1;
    
    			this.Name = "Child";
    
    			this.Text = "Child";
    
     
    
    		}
    
    		#endregion
    
     
    
    		private void menuMain_Popup(object sender, System.EventArgs e)
    
    		{
    
    			// The goal is to dynamically change the child menu items during run time.
    
    			// Then, the new child menu items will be merged into the MDI main menu automatically by the .NET Framework.
    
    			// However, the program crashed after trying to add the following menu item to the MDI menu.
    
    			MenuItem menuItem = new MenuItem("New Menu Item From Child");
    
    			this.menuMain.MenuItems.Add(menuItem);
    
    		}
    
    	}
    
    }
  7. On the Debug menu, click Start to compile and then run the project.
  8. In the new application, click any menu choice. You receive the following error message:
    Object reference not set to an instance of an object
For more information about software update terminology, click the following article number to view the article in the Microsoft Knowledge Base:
824684  (http://kbalertz.com/Feedback.aspx?kbNumber=824684/ ) Description of the standard terminology that is used to describe Microsoft software updates

APPLIES TO
  • Microsoft .NET Framework 1.1
Keywords: 
kbqfe kbfix kbbug kbhotfixserver KB890328
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate

Be the first to leave feedback, to help others about this knowledge base article.

(Optional) Name

(Optional) Public URL Or Email

Comments
No HTML -- Text Only Please