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.
You may not be able to get at that in VB6. previous question.
Get as much information from the Err object.
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
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, 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.
Hope this helps. Good luck!
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.