是否可以在VB6中以编程方式检索调用堆栈? [英] Is it possible to retrieve the call stack programmatically in VB6?

查看:91
本文介绍了是否可以在VB6中以编程方式检索调用堆栈?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当一个函数发生错误时,我想知道导致该错误的事件的顺序,尤其是当从十几个不同的地方调用该函数时。有什么方法可以在VB6中检索调用堆栈,还是必须用困难的方式(例如,在每个函数和错误处理程序中记录日志条目等)?

When an error occurs in a function, I'd like to know the sequence of events that lead up to it, especially when that function is called from a dozen different places. Is there any way to retrieve the call stack in VB6, or do I have to do it the hard way (e.g., log entries in every function and error handler, etc.)?

推荐答案

我很确定您必须采用困难的方法。在我的上一个工作中,我们对带有DCOM组件的VB6有一个非常优雅的错误处理过程。但是,必须在每种方法中添加很多冗余代码,以至于我们拥有了自己开发的工具才能为您全部插入。

I'm pretty sure you have to do it the hard way. At a previous job of mine, we had a very elegant error handling process for VB6 with DCOM components. However, it was a lot redundant code that had to be added to every method, so much that we had home-grown tools to insert it all for you.

我可以对其实施没有太多的了解(两者都是因为我忘记了大多数,而且他们有可能将其视为商业秘密)。突出的一件事是方法名称无法在运行时派生,因此将其作为字符串变量添加(某些开发人员会复制粘贴而不是使用工具,这会导致错误堆栈被掩盖。 ..)。

I can't provide too much insight on its implementation (both because I've forgotten most of it and there's a chance they may consider it a trade secret). One thing that does stand out was that the method name couldn't be derived at run-time so it was added as a string variable (some developers would copy-paste instead of using the tool and it would lead to error stacks that lied...).

HTH

这篇关于是否可以在VB6中以编程方式检索调用堆栈?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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