Is there a way to prevent Visual Studio from breaking on exceptions in a specific method?

后端 未结 3 1683
暖寄归人
暖寄归人 2021-02-07 19:55

I know I can control the way Visual Studio handles exceptions according to their type and to the fact that they\'re eventually caught using the \"Exception\" dialog.

How

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-07 20:20

    I don't want to enable "just my code" debugging

    Yeah, stop there right now. That is exactly the feature you need to not get the unwanted debugger breaks. If you don't want to know about somebody else's crappy code then flip that checkbox back on.

    This invariably goes off the rails when programmers use exceptions for flow control. A very common crime. It takes two of them to turn that into a mess that turns a debugging session into a very tedious click nightmare. When you need the debugger feature that breaks on the first-chance exception then you basically lost if somebody else needed that as well.

    Everybody hopes that they can magically use the [DebuggerNonUserCode] or [DebuggerHidden] or [DebuggerStepThrough] attributes to make that problem disappear. It doesn't. The other programmer did not think his code was unimportant enough to deserve those attributes. And, well, it wasn't because there's always a bug hidden in code that uses try/catch-em-all code. Pokémon code.

    So Microsoft had to find another way to help programmers deal with crappy library code. They did. Tick that checkbox, bam, solved. Nothing you can do about that crappy code anyway, other than sending a nasty-gram to the author. Don't let us or Microsoft slow you down doing that as well, y'all have to get along to create a product that people like to use.

提交回复
热议问题