指向发生异常错误的行 [英] Pointing the Line where I got Exception Error

查看:64
本文介绍了指向发生异常错误的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

当我调试应用程序时,如果发生任何错误,异常块将被执行.我需要找到发生错误的行.(我需要从异常块转到上一行)


有什么办法吗?



谢谢与问候,
Pal.

Hi All,

when I debug the application , if there is any error occurs exception block get executed. I need to find the line where i got the error.(I need to go previous line from exception block)


Is there any way?



Thanks & Regards,
Pal.

推荐答案

Pal.解决此问题的标准方法是实际评估Exception告诉您的内容.在调试版本中,它将包含一个可靠的StackTrace,如果使用.ToString()将其打印出来,则可以获得有关哪一行失败的详细信息.因此,在您的Exception处理程序中,添加以下代码(假设您已调用Exception变量ex).
Pal. The standard way to figure this out is to actually evaluate what the Exception is telling you. In debug builds, it will contain a reliable StackTrace, and if you print it out with .ToString() you get the details of exactly which line failed. So, in your Exception handler, add the following code (assuming that you''ve called your Exception variable ex).
try
{
 ... exception is thrown here.
}
catch (Exception ex)
{
  Debug.WriteLine(ex.ToString());
}


这篇关于指向发生异常错误的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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