简体   繁体   English

调试vb6程序时出现错误错误的调用约定

[英]Error Bad Calling Convention when debugging vb6 program

I have a standard VB 6 exe (mailviewer). 我有一个标准的VB 6 exe(邮件查看器)。
This program has a "link" to a cobol DLL: 该程序具有指向cobol DLL的“链接”:

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

When starting the normal exe from windows, 从Windows启动普通exe时,

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 但是,当我想调试对Visual Studio 6.0(SP6)(在Windows XP中)的cobol DLL入口点的调用时,我得到了

"Error 49, Bad Calling Convention"

Thanks for any help in advance 感谢您的任何帮助

Wolfgang 沃尔夫冈

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. 一切都不好,Cobol函数被设计为可以从C程序中调用。 It has the wrong calling convention, cdecl instead of stdcall. 它使用了错误的调用约定,即cdecl而不是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. 当您从IDE运行时,调试器将执行额外的检查,以验证整个函数调用中堆栈指针是否已正确还原。 It is not, thus generating the error 49 diagnostic. 否,因此生成错误49诊断。

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++. 在VB6中无法解决此问题,这需要用另一种可以进行cdecl调用的语言(如C或C ++)编写一个辅助函数。 The KB article shows what such a function could look like, although they intentionally gave it the wrong convention to demonstrate the problem. KB文章显示了这样一个函数的外观,尽管他们故意给它一个错误的约定以演示该问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM