BUG: You may receive a StackOverflowException exception when you make a child MDI form visible in Visual Studio .NET 2003 and in Visual Studio .NET 2002 (893710)
The information in this article applies to:
- Microsoft Visual Studio .NET (2003), Professional Edition
- Microsoft Visual Studio .NET (2003), Enterprise Architect Edition
- Microsoft Visual Studio .NET (2003), Enterprise Developer Edition
- Microsoft Visual Studio .NET (2003), Academic Edition
- Microsoft Visual Studio .NET (2002), Professional Edition
- Microsoft Visual Studio .NET (2002), Professional Edition SP1
- Microsoft Visual Studio .NET (2002), Enterprise Architect Edition
- Microsoft Visual Studio .NET (2002), Enterprise Architect Edition SP1
- Microsoft Visual Studio .NET (2002), Enterprise Developer Edition
- Microsoft Visual Studio .NET (2002), Enterprise Developer Edition SP1
- Microsoft Visual Studio .NET (2002), Academic Edition
SYMPTOMSIn Microsoft Visual Studio .NET 2003 and in Microsoft Visual
Studio .NET 2002, you may receive a StackOverflowException exception when the following conditions are true:
- You make a child multiple-document interface (MDI) form
visible.
- The parent MDI form is not visible.
CAUSEThis problem occurs when the parent form of a child MDI form
has the Visible property set to false, and you call the Show method of the child MDI form.WORKAROUNDTo work around this problem, make sure that all the parent
forms and controls are visible before you call the Show method of the child MDI form. For example, you can
create a method that recurses through all parent forms and examines the Visible property. The following lines of code demonstrate how you create
this method. private bool allParentsVisible(Control ctl)
{
ctl = ctl.Parent;
while (ctl != null)
{
if (!ctl.Visible)
{
return false;
}
ctl = ctl.Parent;
}
return true;
}
Note This code is also in the code example in step 8 of the "Steps to
reproduce the problem" section. Call the allParentsVisible method before you make the child MDI form visible by using the
following lines of code.
private void btnCheckVisible_Click(object sender, System.EventArgs e)
{
pForm.Visible = false;
// Clearly this will not show the form because the visibility of the parent is false.
// However, in a "real world" application you may not know where the parent form's visibility is
// changed. This is one way to help protect against that.
if (allParentsVisible(cForm))
cForm.Show();
}
STATUSMicrosoft has confirmed that this is a bug in the Microsoft
products that are listed in the "Applies to"
section.
Modification Type: | Minor | Last Reviewed: | 9/13/2005 |
---|
Keywords: | kbvs2002sp1sweep kbtshoot kbbug KB893710 kbAudDeveloper kbAudITPRO |
---|
|