VB6 中的运行时错误堆栈跟踪或位置 [英] Runtime error stacktrace or location in VB6

查看:33
本文介绍了VB6 中的运行时错误堆栈跟踪或位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我维护一个用 VB6 编写的旧应用程序.在客户端的环境中,它会引发我无法在调试器下重现的运行时错误.有什么方法可以获取堆栈跟踪或错误位置吗?

I maintain an old application written in VB6. In client's environment it raises runtime errors which I can't reproduce under debugger. Is there any way to get the stacktrace or location of error?

我的意思是,没有像 这里或添加错误处理程序以记录到每个过程,例如 这里.

I mean, without putting trace statements all over the code like here or adding error handlers for logging to every procedure like here.

这似乎是一个简单的问题.对不起.我只是不太了解VB6.考虑到它被(或曾经)使用的广泛程度,谷歌搜索出任何信息是非常困难的.

It seems to be a simple question. Sorry. I just don't know VB6 very well. And it is surprisingly hard to google out any information, considering how widely it is (or used to be) used.

推荐答案

尝试编译成 pcode 看看是否仍然报错.这是 VB6 的调试模式和运行时之间的一个共同区别.我曾经编译为本机并遇到仅在运行时发生的错误.当我切换到 pcode 时,我发现错误消失了,或者更可能是一个反映实际问题的新错误出现了,并且在调试模式下更容易重现.

Try compiling to pcode and see if you still get the error. This is one common difference between the debug mode of VB6 and runtime. I used to compile to native and ran into errors that only occurred in runtime. When I switched to pcode I found either the error went away or more likely a new error that reflected the real problem cropped up and was more easily reproduced in debug mode.

如果您仍然遇到错误,那么我真的建议您从程序堆栈的顶部开始,并使用 Maero 的建议逐步向下进行

If despite that you still getting the error then I really recommend starting at the top of your procedure stack and working you way down using Maero's suggestion of

On Error Goto Handler
<code>
Exit <routine>
Handler:
Err.Raise Err.Number, "(function_name)->" & Err.source, Err.Description

这是一种痛苦,但没有真正的解决方法.

It is a pain but there is no real way around it.

这篇关于VB6 中的运行时错误堆栈跟踪或位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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