Visual Studio - different sets of breakpoints

2019-09-07 05:19发布

In Visual Studio (2015 and newer), is it possible to have multiple sets of breakpoins? I have several scenarios, I need to debug, but for each of them I would like to have different set of breakpoints. It is quite time-consuming to enable/disable them manually.

1条回答
乱世女痞
2楼-- · 2019-09-07 05:20

You can export and import breakpoints from the breakpoints window and then import them as required.

Visual Studio 15 breakpoints window

Alternatively, if you don't mind modifying your code, you can use conditional breakpoints and set the condition in your code. E.g., set a boolean testingScenario1 = true and then set a breakpoint condition on the breakpoint to only break when testingScenario1 == true.

Or use Debugger.Break(). Something like:

#if DEBUG
    if (testingScenario1)
        Debugger.Break();
#endif
查看更多
登录 后发表回答