Visual Studio 2005 or Visual Studio .NET debugger does not step into the Load event (325118)



The information in this article applies to:

  • Microsoft Visual Studio 2005 Standard Edition
  • Microsoft Visual Studio 2005 Professional Edition
  • Microsoft Visual Studio 2005 Express Edition
  • 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 (2002), Professional Edition
  • Microsoft Visual Studio .NET (2002), Enterprise Architect Edition
  • Microsoft Visual Studio .NET (2002), Enterprise Developer Edition
  • Microsoft Visual Basic 2005
  • Microsoft Visual Basic .NET (2003)
  • Microsoft Visual Basic .NET (2002)
  • Microsoft Visual C# 2005, Express Edition
  • Microsoft Visual C# .NET (2003)
  • Microsoft Visual C# .NET (2002)
  • Microsoft Visual J# 2005 Express Edition
  • Microsoft Visual J# .NET (2003)
  • Microsoft Visual J# .NET (2002)

This article was previously published under Q325118

SYMPTOMS

In Microsoft Visual Studio 2005 or in Microsoft Visual Studio .NET, when you click Step Into on the Debug menu or when you press F11 to start your Microsoft Windows-based application, the debugger does not step into any startup events in the form after the constructor is called. For example, the debugger does not step into the Form Load event.

CAUSE

This problem occurs because the code that is generated between the constructor and the Load event of the form does not have debugger symbols. When the debugger contacts the code that does not have the debugging symbols, it does not step.

WORKAROUND

To work around this issue, set a breakpoint in the event that you want to step through.

STATUS

This behavior is by design.

MORE INFORMATION

Steps to reproduce the issue

  1. In Visual Studio 2005 or in Visual Studio .NET, create a new Windows Application project by using one of the following:
    • Microsoft Visual Basic 2005
    • Microsoft Visual Basic .NET
    • Microsoft Visual C# 2005
    • Microsoft Visual C# .NET
    • Microsoft Visual J# 2005
    • Microsoft Visual J# .NET
    By default, Form1 is created.
  2. In the designer view, double-click Form1 to open the Form Load event in the code view.
  3. Add the following code to the Form Load event:
    • Visual Basic
      System.Diagnostics.Debug.WriteLine("Hello World!")
    • Visual C#
      System.Diagnostics.Debug.WriteLine("Hello World!");
    • Visual J#
      System.Diagnostics.Debug.WriteLine("Hello World!");
  4. Press F11 or click Step Into on the Debug menu to start stepping into the code.
  5. Continue to press F11 to step into the constructor of the Windows form.
  6. After the constructor is executed, the form is displayed without going into the code in the Form Load event.
  7. When you set a breakpoint in the Form Load event, then the execution stops at the breakpoint after it executes the constructor.

    You can continue to step through the Form Load event from this breakpoint.

REFERENCES

For more information, click the following article number to view the article in the Microsoft Knowledge Base:

317297 Roadmap for Debugging Hangs, Memory Leaks, Deadlocks, and Race Conditions in Visual Basic .NET


Modification Type:MinorLast Reviewed:10/3/2006
Keywords:kbvs2005swept kbvs2005applies kbWindowsForms kbForms kbEvent kbDebug kbprb KB325118 kbAudDeveloper