简体   繁体   English

Program.cs 上的 Visual Studio 中断不在引发异常的行上

[英]Visual Studio break on Program.cs not on the line that throws the exception

I have a C# console application.我有一个 C# 控制台应用程序。 In Program.cs , I make calls to a variety of services.Program.cs中,我调用各种服务。 If one of those services throws an Exception , VS breaks in Program.cs and not on the line that is actually responsible for the error.如果其中一项服务引发Exception ,则 VS 在Program.cs中中断,而不是在实际负责该错误的行上。 The modal doesn't even indicate which line threw.模态甚至不指示哪条线抛出。 I understand that you can still get the trace etc., but usually VS breaks on the responsible line which makes debugging far easier.我知道您仍然可以获得跟踪等,但通常 VS 在负责的线路上中断,这使得调试更加容易。

How can I get VS to break on the "external code"?如何让 VS 打破“外部代码”?

在此处输入图像描述

  1. Open Exception Settings from Debug > Windows > Exception Settings从 Debug > Windows > Exception Settings 打开异常设置

  2. Search your exception name.搜索您的异常名称。

  3. Check the checkbox before your exception.在您的异常之前选中复选框。

  4. Uncheck Enable Just My Code in Debug > Options > Debugging > General在 Debug > Options > Debugging > General 中取消选中Enable Just My Code

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 尝试在 Visual Studio 2019 中运行默认 Program.cs (C#) 时出现异常错误 - Getting an exception error when trying to run the default Program.cs (C#) in Visual Studio 2019 在 IIS 上使用 Visual Studio 远程调试器调试 program.cs - debug program.cs using visual studio remote debugger on IIS 仅当从Visual Studio启动时,Program.cs中的Try-Catch才起作用 - Try-Catch in Program.cs only works when started from visual studio 关于从Program.cs调用Visual Studio Forms方法和常规逻辑建议 - Regarding Visual Studio Forms Method Calling From Program.cs and general logic advice 在 Visual Studio 2019 的 Program.cs 文件顶部自动生成注释 - auto generate comments at the top of the Program.cs file in Visual Studio 2019 我正在使用 C# Visual Studio forms。 如何将 Program.cs 中的 var 转换为 VS 表单? - I'm using C# Visual Studio forms. How do I get a var in Program.cs to a VS form? 表格不显示-program.cs - Forms are not displayed - program.cs 一个连接 Program.cs 和 Form.cs - A Connecting Program.cs And Form.cs 为什么我在 Program.cs - C#,Visual Studio 中收到“无法从 'HTMLWriter.HeadingElement' 转换为 'HTMLWriter.TextElement[]'”错误 - Why am I getting a "cannot convert from 'HTMLWriter.HeadingElement' to 'HTMLWriter.TextElement[]'" error in Program.cs - C#, Visual Studio 我正在尝试在 Visual Studio 2022 中使用 .NET 6 将我的 DbContext 注册为我的 program.cs 中的服务,但出现错误。 获取连接字符串 - I am trying to register my DbContext as a service in my program.cs using .NET 6 in Visual Studio 2022, but I get an error on. GetConnectionString
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM