Microsoft KB Archive/832681

From BetaArchive Wiki
Knowledge Base


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

Article ID: 832681

Article Last Modified on 4/29/2007



APPLIES TO

  • Microsoft Visual Studio .NET 2003 Professional Edition
  • Microsoft Visual Studio .NET 2003 Academic Edition
  • Microsoft Visual Studio .NET 2003 Enterprise Architect
  • Microsoft Visual Studio .NET 2003 Enterprise Developer
  • Microsoft Visual Studio .NET 2002 Academic Edition
  • Microsoft Visual Studio .NET 2002 Enterprise Architect
  • Microsoft Visual Studio .NET 2002 Enterprise Developer
  • 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.

  1. Expand Common Language Runtime Exceptions.
  2. Expand System.
  3. Click System.Argument Exception.
  4. 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


Keywords: kbdebug kbexcepthandling kbwindowsforms kbprb KB832681