An exception occurs in the callback function and the Visual Studio .NET debugger does not receive the program control when a callback function does not contain code to handle exceptions in the try/catch block (832681)



The information in this article applies to:

  • Microsoft Visual Studio .NET (2003), Professional Edition
  • Microsoft Visual Studio .NET (2003), Academic Edition
  • Microsoft Visual Studio .NET (2003), Enterprise Architect Edition
  • Microsoft Visual Studio .NET (2003), Enterprise Developer Edition
  • Microsoft Visual Studio .NET (2002), Academic Edition
  • Microsoft Visual Studio .NET (2002), Enterprise Architect Edition
  • Microsoft Visual Studio .NET (2002), Enterprise Developer Edition
  • Microsoft Visual Studio .NET (2002), Professional Edition

SYMPTOMS

When a callback function does not contain code to handle exceptions in the try/catch block, an exception may occur in the callback function and the Microsoft Visual Studio .NET debugger may not receive the program control. The unhandled exception that appears in the Call Stack window may not be the expected exception.

CAUSE

This problem occurs because the Microsoft .NET Framework handles the exception and then rethrows the exception to the debugger. The debugger may not provide the correct location of the exception.

RESOLUTION

To resolve this problem, set the Exceptions option to Break into the debugger for the first-chance exceptions in your debug exceptions, as follows:
  1. Open a project in the Visual Studio .NET IDE.
  2. On the Debug menu, click Exceptions.

    The Exceptions dialog box appears.
  3. Expand Common Language Runtime Exceptions.
  4. Expand System.
  5. Click System.Argument Exception.
  6. Under When the exception is thrown, click Break into the debugger. Click OK.

STATUS

This behavior is by design.

REFERENCES

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

105675 INFO: First and second chance exception handling


For more information, visit the following Microsoft Web site:

Modification Type:MinorLast Reviewed:4/6/2004
Keywords:kbDebug kbExceptHandling kbWindowsForms kbprb KB832681 kbAudDeveloper