VS2015中的异常配置

The New Exception Settings Window in Visual Studio 2015
Managing Exceptions with the Debugger

Understanding Exceptions while debugging with Visual Studio 7 Jan 2015 7:24 PM

Configuring the debugger to break for first chance exceptions

To change when the debugger breaks, go to Debug->Windows->Exception Settings

VS2015中的异常配置

When you first open this window you will see that there is a tree grid with one column and checkboxes.

  • Break when Thrown. This includes a default list of exceptions known by the debugger, grouped by category. 
    Note: The possible exceptions that could break from this list is determined by the runtime you are debugging. For example, if you are using managed-only debugging then the debugger will never break for C++, Win32 Exceptions, etc. even if they are configured to break when thrown.
  • Checkboxes. If you check the box for a category, then the debugger will break for all First Chance Exceptions while debugging. If you don’t want to enable all First Chance Exceptions, you can find the specific exception types that you wish to configure by using the search box.

Using the context menu, you can show the Additional Actions column and also configure the behavior for user-unhandled exceptions.

VS2015中的异常配置

  • Additional Actions. This column is only available if Just My Code is enabled. User-unhandled exceptions only make sense for Common Language Runtime Exceptions and JavaScript Runtime Exceptions, the option to configure this for other runtimes is not available because the debugger does not make distinctions between user code and External Code. As per my earlier comments, you typically do not want to turn this off. If you do wish to turn this off, you can do so by selecting “Continue when unhandled in user code” from the context menu.

This list is not an exhaustive master list of every possible exception. You can use Add and Remove to manage exceptions in this default list. This configuration is saved with your solution. You can also use search to locate all of the exceptions with specific keywords, e.g. “null”. Lastly you can use Reset All to restore the list to its default state.

Example

For this example we are using a simple WPF app that is supposed to draw a shape in the window when the user clicks a button. This app has been implemented to display “Failure” text in the view when something goes wrong and “Success” when everything has gone right. You can follow along with the code attached to this post.

Let’s pretend I was given this app to test out and make sure everything was working.

  • I start debugging (F5) to run the app.
  • Click on “Draw Half Octagon”.
  • Observe Failure Message.
上一篇:[Java 进阶]Java中的国际化


下一篇:iOS 解决LaunchScreen中图片加载黑屏问题