FIX : Menu Items Leak When Added to a Menu Bar on a Windows Form

Article translations Article translations
Article ID: 817723 - View products that this article applies to.
This article has been archived. It is offered "as is" and will no longer be updated.
Expand all | Collapse all

SYMPTOMS

When a menu item is added to a menu bar that is already present on a Windows Form, then n-1 menu items leak when you close that form (where n is the number of menu items that are already on the form). You notice this behavior as an increase in the GDI Object count that Windows Task Manager displays as the operation continuously repeats.

To view the GDI Object count in Task Manager, open the Task Manager window, and then click View on the menu bar. Click Select Columns..., and then check GDI Objects.

RESOLUTION

A supported hotfix is now available from Microsoft, but it is only intended to correct the problem that is described in this article. Only apply it 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 service pack that contains this hotfix.

To resolve this problem immediately, contact Microsoft Product Support Services to obtain the hotfix. For a complete list of Microsoft Product Support Services telephone numbers and information about support costs, visit the following Microsoft Web site:
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.

The English version of this hotfix has the file attributes (or later) 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 tool in Control Panel.
Date         Time   Version       Size       File name
---------------------------------------------------------------------
27-May-2003  17:52                   16,684  System.Windows.Forms.ldo 
27-May-2003  17:48  1.0.3705.429     57,344  System.Windows.Forms.tlb 
28-May-2003  17:00  1.0.3705.429  1,990,656  System.Windows.Forms.dll 
28-May-2003  17:01  1.0.3705.429  1,179,648  System.Data.dll 
28-May-2003  17:01  1.0.3705.429  1,695,744  System.Design.dll 


MORE INFORMATION

For any forms that have MainMenu components, add the following code to make sure the components are disposed of correctly:
protected override void Dispose(bool disposing) 
     { 
     If (disposing) 
          { 
          If (components != null) 
               { 
               components.Dispose(); components = null; 
               } 
          If (mainMenu1 != null) 
               { 
// Code to add 
               mainMenu1.Dispose(); 
//             mainMenu1 = null; 
//             }
//        }
      base.Dipose(disposing); 
      } 
Because absolute ownership of menus cannot be determined in Microsoft Visual Studio .NET, this hotfix will not address certain scenarios that are resolved by the addition of this code. For example, menus may be shared between forms. Therefore, the form does not dispose of the menu automatically. This disposal code is necessary for any subforms. The same applies for any top-level forms that close without exiting the application.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

Properties

Article ID: 817723 - Last Review: October 26, 2013 - Revision: 2.3
APPLIES TO
  • Microsoft .NET Framework 1.0 Service Pack 2
Keywords: 
kbnosurvey kbarchive kbhotfixserver kbqfe kbnetframe100sp2fix kbnetframe100presp3fix kbfix kbbug KB817723

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com