BUG: Creating circular references between UserControls closes Visual Basic .NET without a warning (316554)



The information in this article applies to:

  • Microsoft .NET Framework SDK 1.0
  • Microsoft Visual Basic .NET (2002)
  • Microsoft Visual C# .NET (2002)

This article was previously published under Q316554

SYMPTOMS

When you use Visual Basic .NET to create two Windows Control Libraries (UserControls) that have a circular reference between them, and then you try to add one control onto another, the integrated development environment (IDE) may close (crash) without warning.

CAUSE

The stack overflow exception is not properly trapped.

RESOLUTION

To work around this problem, do not use circular references between the UserControls.

STATUS

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

MORE INFORMATION

Steps to Reproduce Behavior

  1. Start a new Windows Control Library project using Visual Basic .NET. UserControl1 is created by default.
  2. On the Project menu, click Add User Control, and then add UserControl2 to the project.
  3. Double-click the UserControl1 designer to view the code.
  4. Above the UserControl1_Load sub, type the Dim u as New UserControl2 statement so that the code resembles the following:
    Dim u As New UserControl2()
    Private Sub UserControl1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
    End Sub
    					
  5. Repeat steps 3 and 4 for UserControl2 so that the code resembles the following:
    Dim u As New UserControl1()
    Private Sub UserControl2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
    End Sub
    					
  6. On the Build menu, click Build Solution.
  7. In the Toolbox on the designer for UserControl1, double-click UserControl2 to add it to UserControl1.
When you perform the same steps in Visual C#, you experience slightly different behavior. The IDE does not close immediately. The Just-In-Time (JIT) debugger starts with the following error message:
An exception 'System.StackOverflowException' has occurred in DefaultDomain.

If you click No to dismiss the JIT dialog box, then the IDE closes without warning.

Modification Type:MinorLast Reviewed:8/18/2005
Keywords:kbvs2002sp1sweep kbbug kbpending KB316554