【发布时间】:2020-03-02 21:53:20
【问题描述】:
我有一个正在远程调试的 .NETCore 3 Blazor 项目。远程调试器输出窗口和 chrome 控制台中都会出现异常。但无论我更改什么配置,VS 都拒绝中断任何这些异常。
我听从了this 帖子中的建议:
- 在工具 > 选项 > 调试下选中“仅启用我的代码”
- 禁用“在用户代码中未处理时继续”标志
因为我有一个全局异常处理程序(请参阅 ASP.NET 顶级异常处理程序上的 note)
- “要恢复 VS 在未处理的异常上中断的行为,我必须勾选我想要中断的所有异常类型,然后确保“附加选项”(您可能需要使此列可见* ) 用于“未设置用户代码中未处理时继续”(x)
我的配置:
输出窗口中打印的异常(例如,抛出的其他异常也不会中断):
System.InvalidOperationException: This instance has already started one or more requests. Properties can only be modified before sending the first request.
at System.Net.Http.HttpClient.CheckDisposedOrStarted()
at System.Net.Http.HttpClient.set_Timeout(TimeSpan value)
at [...].Web.Client.Pages.DiagnosticsBase.CreateMIO() in C:\[...]\Diagnostics.razor.cs:line 94
at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__139_0(Object state)
at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.ExecuteSynchronously(TaskCompletionSource`1 completion, SendOrPostCallback d, Object state)
at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.<>c.<.cctor>b__23_0(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.ExecuteBackground(WorkItem item)
chrome 控制台中打印的异常:
我还检查以确保 System.InvalidOperationException 被检查为在抛出时中断,没有条件或其他操作:
在我的远程调试会话期间,断点似乎工作正常。我正在远程调试与远程服务器上运行的相同版本的代码,并且服务器正在运行在 Debug 配置中构建的代码。
我在这里做错了什么?我很困惑,我觉得我一定是误解了设置,因为我找不到调试器没有中断的原因。
【问题讨论】:
-
有时构建配置会影响这一点。 IE。选择调试,从下拉列表中释放。
标签: c# asp.net-core exception remote-debugging visual-studio-2019