Stack Trace in VB6

人走茶凉 提交于 2019-12-01 05:27:34

问题


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.


回答1:


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.




回答2:


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




回答3:


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.




回答4:


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.




回答5:


You may not be able to get at that in VB6. previous question.
Get as much information from the Err object.



来源:https://stackoverflow.com/questions/3367980/stack-trace-in-vb6

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!