Question

I have a Visual Basic 4 32 bit application which results in a

Run-time error '5':
Invalid procedure call

I start WinDbg and do

sxe *

to break on all exceptions. However, it displays the message without breaking into the debugger before.

If I break at the time of the message, the callstack is not very useful. Is there a trick to break-in on Visual Basic 4 applications at the time the problem occurs?

Problem FAQ:

  • Can you run it in the IDE?
    Yes I can and I can probably fix the bug when I do that. However, I'd like to get some more information at the time the end user runs the application so that I don't need to be able to reproduce it.

  • What do you want to do in case you find the cause of the error?
    Well, it depends on the type of the error. Maybe I can fix it, maybe I can't. Usually I get some very helpful information out of WinDbg.

  • When does the error occur?
    It occurs reproducibly when the user presses a close button on a form.

  • What does the application do?
    Oh, that's a good question. I don't exactly know. It uses RS232 communication but it's not yet involved.

  • Do you know anything about the data the user can enter?
    I almost know nothing about it. In this particular case, it's not necessary to enter data.

Was it helpful?

Solution

The error is from the VB virtual machine not from an API. I can't see how WinDbg would be useful on VB4 which is interpreted and is in P-Code.

Visual Basic run-time error 5 Indicates one of the following:

  • An invalid collection or property name was entered.
  • An out parameter was NULL.
  • The value is not one of the supported values or falls outside the supported range.
  • The property is read-only.
  • The property cannot be changed after the object is created.
  • An invalid index was entered.

And in case it's an API call VB uses LoadLibrary and GetProcAddress.

Some controls have lost default values over time and this can cause the first.

The third can happen if modern technology exceeds the program's expection, e.g. disk space.

Also see (sorry no links, they are on my hard disk)

Q131007 HOWTO: Use Windows NT WinDbg.exe with Visual Basic (it's for NT 3.5)

Q166275 HOWTO: Debug a Native Code Visual Basic Component in VC++ (talks about what you can see in VB in a debugger)

VB4 can't make symbols

OTHER TIPS

As the error occurs when the users presses the close button i assume there is a (very tight) loop running which doesn't receive the expected data (probably a nullstring)

I expect that that loop is continuously reading data from the RS232 device and the RS232 is on the form which is being closed, even though it is not involved the connection might already be open and polling

What you should do is exit that loop and close the connection with the RS232 device before closing the form. You might be able to do that in the Form_Unload() event, but it might also have to take place before that, so you might have to do it in the code of the close button ... make sure though that the user won't be using the X to close the form though

Personally i would run the program from within the IDE, this will point you to the errornous part of the code directly and gives you the opportunity to watch the contents of the variables involved and control states ... that is much faster than taking a guess based on the data of WinDbg

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top