在Visual Studio 2019中引发用户处理的异常时如何不中断 [英] How to not break when user handled exception is thrown in visual studio 2019

查看:1265
本文介绍了在Visual Studio 2019中引发用户处理的异常时如何不中断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Microsoft Visual Studio Enterprise 2019
Version 16.5.5
VisualStudio.16.Release/16.5.5+30104.148
Microsoft .NET Framework
Version 4.8.03752

当发生以下异常时,我不希望Visual Studio在调试模式下中断.我通过尝试处理的那些.但是,即使我进行了广泛的互联网搜索,我也找不到办法

项目详细信息:asp.net Web表单,.net 4.8框架

解决方案

在视觉上引发用户处理的异常时如何不中断 Studio 2019

首先,感谢 Jazimov 分享了精彩的建议.

实际上,要在调试模式下停止破坏特定异常(System.NullReferenceException),您应该尝试Jazimpv的建议.

调试-> Windows -> 异常设置-> 公共语言运行时异常

取消选中System.Null.ReferenceException

此功能只是防止异常中断调试,但不会阻止异常的发生. 尽管虽然它没有出现在代码编辑器"中,但也会被输出窗口捕获.

但是,如果不中断调试模式,就无法直接在代码编辑器中获得最直接的异常.

为了获得更详细的异常信息,您可以将其编写为显示在输出"窗口中:

  try
  {

     .........          
  }
  catch(Exception ex) 
  {
          Debug.WriteLine("=============================");
          Debug.WriteLine(ex.Message);
          Debug.WriteLine(ex.Source);
          Debug.WriteLine(ex.StackTrace);
          Debug.WriteLine("=============================");          
  }

Microsoft Visual Studio Enterprise 2019
Version 16.5.5
VisualStudio.16.Release/16.5.5+30104.148
Microsoft .NET Framework
Version 4.8.03752

I don't want visual studio to break in debug mode when such as below exceptions happened. The ones that i have handled via try catch. But i could not find a way even though I did extensive internet search

project details : asp.net web forms, .net 4.8 framework

解决方案

How to not break when user handled exception is thrown in visual studio 2019

First, thanks to Jazimov for sharing the wonderful suggestion.

Actually, to stop breaking the specific exception(System.NullReferenceException) during Debug mode, you should try Jazimpv's suggestion.

Debug-->Windows-->Exception Settings-->Common Language Runtime Exceptions

uncheck System.Null.ReferenceException

This feature simply prevents exceptions from interrupting debugging, but does not block the occurrence of exceptions. Although it does not appear in the Code Editor, it will also be caught by the output window.

However, you can't get the most straightforward exception directly in the code editor without interrupting the debugging mode.

In order to get more detailed exception information, you can write this to show on Output Window:

  try
  {

     .........          
  }
  catch(Exception ex) 
  {
          Debug.WriteLine("=============================");
          Debug.WriteLine(ex.Message);
          Debug.WriteLine(ex.Source);
          Debug.WriteLine(ex.StackTrace);
          Debug.WriteLine("=============================");          
  }

这篇关于在Visual Studio 2019中引发用户处理的异常时如何不中断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆