Object Leak in Measurement Studio 2015 "Error creating window handle"

Updated Jan 5, 2018

Reported In

Software

  • Measurement Studio Standard

Issue Details

After running for some time, my Measurement Studio 2015 program crashes with an error message that says Error creating window handle. What is this and how do I fix it? 
USER Object Error

Solution

This error can occur because the program has used all the USER objects available, and cannot create new window handles. 

A USER object is a handle associated with some item on the user interface. USER objects can be overutilized if too many user interface objects are created (on the order of 10,000) or if an object is repeatedly creating USER objects and not disposing of them. 

There is a known USER object leak in Measurement Studio 2015, in projects which make use of Toolstrip Property Editor objects. Each instance of the Toolstrip Property Editor object creates a new USER object but does not dispose of it when the containing object is disposed. Toolstrip Property Editor objects should be explicitly disposed in the dispose method of the containing object. This issue is documented in CAR 622545.

You can explicitly dispose of the Toolstrip Property Editor objects by navigating to the Designer code of the form with which the Toolstrip Property Editor object is associated and adding code to the Dispose method. By default, the Dispose method appears as follows: 
protected override void Dispose(bool disposing)
{
    if (disposing && (components != null))
    {
        components.Dispose();
    }
    base.Dispose(disposing);
}
For each Toolstrip Property Editor object, a dispose method needs to be added. An example Dispose method with two Toolstrip Property Editor objects is shown below: 
protected override void Dispose(bool disposing)
{
    toolStripPropertyEditor1.Dispose();
    toolStripPropertyEditor2.Dispose();
    if (disposing && (components != null))
    {
        components.Dispose();
    }
    base.Dispose(disposing);
}

WAS THIS ARTICLE HELPFUL?

Not Helpful