如何访问和使用堆栈跟踪来帮助识别错误 [英] How to access and use the stack-trace to help identify a bug

查看:21
本文介绍了如何访问和使用堆栈跟踪来帮助识别错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到很多人发帖说他们收到了这样那样的错误,但似乎不知道如何找出错误的来源.

I see a lot of posts from people saying they get error such and such but seem to have no idea how to figure out where the error is coming from.

因此,我想知道人们是否知道如何访问和使用堆栈跟踪.

As such I wondered if people know how to access and use the stack trace.

那么您如何访问它,它对您有什么意义和作用?

So how do you access it, and what does it mean and do for you?

推荐答案

当您收到如下所示的错误消息时,请单击查看详细信息.. 链接.

When you get an error message as shown below click on the View Detail.. link.

这将打开此属性框.

展开异常以显示详细信息并将鼠标悬停在 StackTrace 属性上.

Expand the exception to show the details and hover the mouse over the StackTrace property.

您在此处看到的大部分内容可能都是希腊语(向阅读本文的希腊朋友道歉),但是如果您仔细观察,您会看到

Most of what you see listed there will probably be Greek to you (Apologies to the Grecian friends reading this), but if you look closer you will see lines that say

在NAME OF A MODULE":第 230 行(或其他地方)

at "NAME OF A MODULE":Line 230 (or wherever)

跟踪中类似的第一行是最终导致代码崩溃的行.只需在您的代码中找到该行并尝试找出该特定行导致指定错误的原因.

The first line like that in the trace is the line that finally crashed the code. Simply go find that line in your code and try and figure out why that particular line is causing the specified error.

该格式的后续行是代码中调用上述例程的点.

Subsequent lines of that format are the point in your code where the routine listed above was called from.

现在上面的图像不是一个很好的例子,因为 IDE 调试器在错误行处停止.但无论如何,当您在 try/catch 语句中正确捕获错误时,堆栈跟踪非常宝贵.异常的属性之一是堆栈跟踪......查看它或将其转储到即时窗口.

Now the images above are not a very good example since the IDE debugger stopped at the error line. But regardless, the stack-trace in invaluable when you properly trap errors in a try / catch statement. One of the properties of the exception is the stack-trace.. view it or dump it to the immediate window.

    Try

    Catch ex As Exception
        Debug.Print(ex.StackTrace)
    End Try

此外,在运行 exe 版本时,请熟悉详细信息窗格.它的堆栈跟踪相同.

Also when running the exe version be familiar with the details pane. Its the same stack-trace.

这篇关于如何访问和使用堆栈跟踪来帮助识别错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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