简体   繁体   English

使用异步方法时如何调试异常

[英]how to debug exceptions when using async methods

In asp.net MVC, when I'm debugging and stepping over code, the debugger will stop at an offending line and show me the exception being thrown without the line being in a try..catch. 在asp.net MVC中,当我调试和遍历代码时,调试器将在有问题的行停止,并向我显示在try..catch中没有抛出该行的情况。 However, when working with lines that are await..async, the debugger doesn't pause and the exception is just returned back as a response before I have a chance to see it in debugger. 但是,当使用等待..async的行时,调试器不会暂停,并且在我有机会在调试器中看到异常之前,该异常只是作为响应返回。 Is there a setting in VS2017, where I can pause the debugger and examine this exception when calling async methods? VS2017中是否有设置,可以在其中调用调试方法时暂停调试器并检查此异常?

Just place a break-point manually in the desired method ahead of time by pressing F9 there. 只需提前按所需的方法以手动方式将断点放在此处即可,方法是按F9 First line of code in that method is a good logical place. 该方法中的第一行代码是一个很好的逻辑位置。 Then launch a debugger and do usual F10 or F5 as work your way. 然后启动调试器并按照您的方式进行常规的F10F5 At some point (which you don't control) you'll be stopped at desired point. 在某个时刻(您无法控制),您将在所需的时刻停止。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM