VB6 中的堆栈跟踪

发布于 2024-09-12 05:59:34 字数 154 浏览 9 评论 0原文

是否可以获取 Visual Basic 6.0 中的堆栈跟踪信息。我的意思是我想找出导致错误的函数名称和确切行,类似于 .NET 堆栈跟踪。我创建了一个 ActiveX DLL,它在我的测试环境中工作正常,但在生产环境中抛出错误(错误:91-对象变量或未设置块变量)。对此的任何帮助都非常感谢。

Is it possible to get the stack trace information in Visual Basic 6.0. I mean I want to find out the function name and exact line that causes the error similar to .NET stack trace. I have created an ActiveX DLL which works fine in my test environment but it throws an error in production environment(error : 91-Object variable or With block variable not set). Any help on this much appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

草莓酥 2024-09-19 05:59:34

这是一个好方法 - 对现有重复问题的回答。使用 MZTools 自动插入错误处理程序


或者,您可以使用 WinDBG,来自 Microsoft 的免费独立调试器。使用符号将 DLL 编译为本机代码(创建 PDB 文件)。

这是 Microsoft 人员的 2006 年博客文章,内容涉及将 Windbg 与 VB6 结合使用,以及 2004 年博客文章 另一位 Microsoft 人员对 Windbg 进行了简要介绍。

This is a good way to do it - an answer on the existing duplicate question. Use MZTools to insert the error handlers automatically


Alternatively, you can debug your built DLL in the production environment using WinDBG, a free standalone debugger from Microsoft. Compile your DLL into native code with symbols (create PDB files).

Here's a 2006 blog post by a Microsoft guy about using Windbg with VB6, and 2004 blog post by another Microsoft guy with a brief introduction to Windbg.

沫雨熙 2024-09-19 05:59:34

唯一的选择是使用 VB6 的错误处理手动执行此操作。
这是一个例子:
http://www.vbaccelerator.com/home/vb/代码/技术/RunTime_Debug_Tracing/article.asp

The only option is to do it manually, with VB6's error handling.
Here is an example:
http://www.vbaccelerator.com/home/vb/code/Techniques/RunTime_Debug_Tracing/article.asp

风轻花落早 2024-09-19 05:59:34

我首选的方法是 HuntERR ;它受到许可,因此可以在任何项目中不受惩罚地使用。

http://www.devx.com/vb2themax/Tip/19792

这是一个非常好的VB6 的静态库,允许完整的堆栈跟踪,其中包含您想要包含的尽可能多的信息。

IDE 中的一些自动化功能可以插入错误处理程序和行号,这会给它带来巨大的好处。

链接的存档有许多我不熟悉的额外内容,包括似乎是 VB6 IDE 插件 - 我将把它添加到我的 VB6 工具包集合中。

这个库确实可以让你不再“嗯?”具有完整行编号的堆栈跟踪,如果正确使用,它可以为 VB6 提供专业级别的错误处理。

My preferred method for doing this is HuntERR ; it's under a permissive license so can be used with impunity in any project.

http://www.devx.com/vb2themax/Tip/19792

This is an excellent static library for VB6 that permits full stack traces with as much information as you care to include.

It benefits tremendously from having some automation in your IDE to insert the error handlers and line numbers.

The archive as linked has a number of extras that I am not familiar with, including what seems to be a VB6 IDE addin - I shall be adding this to my collection of VB6 kit.

This library can literally take you from going "HUH?" to having a stack trace with full line numbering, it gives VB6 an professional level of error handling when used correctly.

只怪假的太真实 2024-09-19 05:59:34

VB6 似乎没有一个很好的方法来实现这一点。

这有点麻烦,但您可以组合一个自定义解决方案,以便在需要时向文本文件添加行。在某个地方放置一个如下所示的方法:

Public Sub LogCall(message as String)
    Open "c:\My Documents\sample.txt" For Output As #1
    Print #1, message
    Close #1
End Sub

然后从您自己的函数中手动调用它

LogCall "MyFunction: Line 42"

它并不能解决问题,但它可能会帮助您缩小问题范围。

关于您的具体错误,我会仔细检查并检查您将对象分配给变量的情况 - 我发现很容易忘记 Set 关键字并在我时得到完全相同的错误最不期待它。

VB6 doesn't seem to have a decent way to do that natively.

It's a bit cumbersome, but you could put together a custom solution that adds lines to a text file whenever you want it to. Put together a method somewhere that looks like this:

Public Sub LogCall(message as String)
    Open "c:\My Documents\sample.txt" For Output As #1
    Print #1, message
    Close #1
End Sub

and then manually call it from your own functions

LogCall "MyFunction: Line 42"

It doesn't solve the problem, but it might help you narrow it down.

With regards to your specific error, I would go through and check situations where you're assigning an object to a variable - I find that it's easy to forget the Set keyword and get the exact same error when I least expect it.

放肆 2024-09-19 05:59:34

您可能无法在 VB6 中实现这一点。 上一个问题

Err 对象获取尽可能多的信息< /a>.

You may not be able to get at that in VB6. previous question.

Get as much information from the Err object.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文