Freigeben über


Exception Handling (Debugging)

An exception is an abnormal situation that happens while a program is running. Exceptions are frequently indications of problems that you have to debug. When an exception occurs, the debugger writes an exception message to the Output window, unless it is disabled in the General, Debugging, Options Dialog Box dialog box.

The debugger might or might not break execution when exception occurs.

  • If a non-ASP.NET exception occurs and is not handled, the debugger always breaks execution.

  • You can tell the debugger to break execution immediately when an exception is thrown, before any handler is invoked. For more information, see How to: Break When an Exception is Thrown.

  • If you are debugging with Just My Code, you have a third option. You can tell the debugger to break on any exception that is not handled by a handler in user code ("My Code"). For more information, see How to: Break on User-Unhandled Exceptions.

  • ASP.NET has a top-level exception handler that handles exceptions to show error pages to browser users. That top-level exception handler will stop an unhandled exception from breaking into the debugger unless Just My Code is turned on. Make sure that you enable Just My Code for ASP.NET debugging.

    Remember, if an exception occurs and is not handled at all, the debugger always breaks. The user-unhandled setting does not change that.

The Visual Studio debugger recognizes the following categories of exceptions:

  • C++ exceptions

  • Common language runtime exceptions

  • Managed debugging assistants

  • Native run-time checks

  • Win32 exceptions

  • Javascript runtime exceptions

  • GPU memory access exceptions

Most exceptions have handlers that are designed to respond to an exception when it occurs. This gives the program an opportunity to recover from the abnormal situation. Native run-time checks do not have handlers.

In a Visual Basic application, the debugger represents all errors as exceptions, even if you use On Error–style error handlers.

For Visual Basic, and C#, the debugger now features a new Exception Assistant that provides more information when an exception occurs.

The following topics provide information on handling exceptions:

See Also

Concepts

Debugger Security

Other Resources

Exception Assistant

Debugger Roadmap

Just My Code