Error Bad Calling Convention when debugging vb6 program

Wolfgang Adamec

I have a standard VB 6 exe (mailviewer).
This program has a "link" to a cobol DLL:

Declare Sub InkMvwMail Lib "inkvwm" Alias "INKMVWMAIL" ...

When starting the normal exe from windows,

EVERYTHING WORKS FINE,

but when I want to debug the call to the cobol DLL entry point in Visual Studio 6.0 (SP6) (on windows xp), I get

"Error 49, Bad Calling Convention"

Thanks for any help in advance

Wolfgang

Hans Passant

EVERYTHING WORKS FINE,

No, it only looks that way. Everything is not fine, that Cobol function was designed to be called from a C program. It has the wrong calling convention, cdecl instead of stdcall. The stack imbalance that's caused by this can cause extremely hard to diagnose runtime failure, like local variables mysteriously having the wrong value and includes the hard crash for which this site is named.

When you run from the IDE, the debugger performs an extra check to verify that the stack pointer is properly restored across the function call. It is not, thus generating the error 49 diagnostic.

You'll need to follow the guidance in this KB article. It cannot be solved in VB6, this requires writing a little helper function in another language that can make cdecl calls, like C or C++. The KB article shows what such a function could look like, although they intentionally gave it the wrong convention to demonstrate the problem.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Error Bad Calling Convention when debugging vb6 program

From Dev

Tracing VB6 runtime error by debugging it

From Dev

VB6 - debugging program to assist with compiled program

From Dev

Excel VBA: "Run-time error '49': Bad DLL calling convention" calling C++ dll

From Java

When to use a certain calling convention

From Dev

loadFileSystems error when calling a program that uses libhdfs

From Dev

What is better to declare for calling convention of Windows program?

From Dev

Why error is caught when calling to a missing function, and not on a bad statements?

From Dev

Why error is caught when calling to a missing function, and not on a bad statements?

From Dev

ASP.NET project calling a VB6 Ddll, error REGDB_E_READREGDB

From Dev

Forcing the VB6 compiler to use early binding when calling a .net com dll

From Dev

VB6 program when run as schedule task freezes until focused

From Dev

Error with averaging program (Java), (Debugging)

From Dev

calling mysql query in vb6

From Dev

Program giving bad alloc error

From Dev

VB6 CALC Aggregation on ADO Shape when returns Null getting General Error in Data Report

From Dev

Inserting Gif in VB6 Program

From Dev

debugging macro - unbound variable when calling

From Dev

How to resolve a Bad global or local ref passed to JNI error when calling a java method from native code

From Dev

Avoiding "Error: Calling convention doesn't match forward" in FPC mode

From Dev

Debugging java bank account program (1 error)

From Dev

Bad Compile Error Calling Scala from Java

From Dev

My program runs correctly while debugging, but incorrectly when out of debugging

From Dev

InputSimulator works while debugging but not when program is built

From Dev

BAD_ACCESS when calling CSSearchableIndex indexSearchableItems

From Dev

EXC_BAD_ACCESS when calling printf()

From Dev

Change parameters On error in vb6

From Dev

Dir function in VB6 - Error 5

From Dev

Dir function in VB6 - Error 5

Related Related

  1. 1

    Error Bad Calling Convention when debugging vb6 program

  2. 2

    Tracing VB6 runtime error by debugging it

  3. 3

    VB6 - debugging program to assist with compiled program

  4. 4

    Excel VBA: "Run-time error '49': Bad DLL calling convention" calling C++ dll

  5. 5

    When to use a certain calling convention

  6. 6

    loadFileSystems error when calling a program that uses libhdfs

  7. 7

    What is better to declare for calling convention of Windows program?

  8. 8

    Why error is caught when calling to a missing function, and not on a bad statements?

  9. 9

    Why error is caught when calling to a missing function, and not on a bad statements?

  10. 10

    ASP.NET project calling a VB6 Ddll, error REGDB_E_READREGDB

  11. 11

    Forcing the VB6 compiler to use early binding when calling a .net com dll

  12. 12

    VB6 program when run as schedule task freezes until focused

  13. 13

    Error with averaging program (Java), (Debugging)

  14. 14

    calling mysql query in vb6

  15. 15

    Program giving bad alloc error

  16. 16

    VB6 CALC Aggregation on ADO Shape when returns Null getting General Error in Data Report

  17. 17

    Inserting Gif in VB6 Program

  18. 18

    debugging macro - unbound variable when calling

  19. 19

    How to resolve a Bad global or local ref passed to JNI error when calling a java method from native code

  20. 20

    Avoiding "Error: Calling convention doesn't match forward" in FPC mode

  21. 21

    Debugging java bank account program (1 error)

  22. 22

    Bad Compile Error Calling Scala from Java

  23. 23

    My program runs correctly while debugging, but incorrectly when out of debugging

  24. 24

    InputSimulator works while debugging but not when program is built

  25. 25

    BAD_ACCESS when calling CSSearchableIndex indexSearchableItems

  26. 26

    EXC_BAD_ACCESS when calling printf()

  27. 27

    Change parameters On error in vb6

  28. 28

    Dir function in VB6 - Error 5

  29. 29

    Dir function in VB6 - Error 5

HotTag

Archive