Vb6 应用程序可以在 IDE 中运行,但可执行文件崩溃

发布于 2024-07-30 12:28:08 字数 201 浏览 3 评论 0原文

我对 Visual Basic 6 项目有一个小问题。 IDE 中一切正常 但是当我运行应用程序时,可执行文件每次都会崩溃。 应用程序使用回调与 C++ dll 进行通信。 当回调开始时,即使是像显示消息框这样简单的代码也会失败。

我将编译模式更改为P-Code,问题仍然存在。

任何帮助将不胜感激。

谢谢你们

I have a little problem with visual basic 6 project. Everything works fine in the IDE
but the executable crashes every time, when I run the application. The application uses callbacks to communicate with a C++ dll. Even code as simple as showing a message box fails when the callback starts.

I changed the compilation mode to P-Code and still the problem persist.

Any help would be appreciate.

Thank you all

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

假面具 2024-08-06 12:28:08

这听起来像是回调可能发生在与您的应用程序执行的线程不同的线程上。 [编辑:据我所知吉姆已经建议了。]如果是这样的话,是的,只要你“触摸”任何东西,就会kaboom OLE 相关或调用到运行时。 与多媒体计时器回调相同的故事,fwiw,我怀疑如果是这种情况,您将必须采取与处理这些回调相同的预防措施。

具有不同线程回调的简短故事是,您需要使用类型库中声明的 PostMessage 向自己发送一条消息,以便 VB 不会设置 Err 对象,然后让回调返回。 您在收到发布的消息后自行进行处理。 这是我在 CCRP Timers 库中使用的类型库:

http://vb.mvps.org/tools/files/postmessage.zip

希望有帮助...

This sounds like the callbacks may be occurring on a different thread than your application is executing on. [EDIT: As I see Jim has already suggested.] If that's the case, yeah, kaboom just as soon as you "touch" anything OLE related or call into the runtime. Same story as with multimedia timer callbacks, fwiw, and I'd suspect you'll have to take the same precautions as one would with those if this is the case.

The short story with different thread callbacks is that you'll need to post a message to yourself, using PostMessage declared in a typelib so that the Err object isn't set by VB, then let the callback return. You do your own processing on receipt of the posted message. Here's the typelib I used for this with the CCRP Timers library:

http://vb.mvps.org/tools/files/postmessage.zip

Hope that helps...

鲜血染红嫁衣 2024-08-06 12:28:08

谁给谁回电话? 向我们展示一些代码。

IDE 可以掩盖真正的问题,因此仅仅能够运行并不能保证您正在做的事情得到支持。

回调的一个常见问题是 VB6 的运行时不是线程安全的,因此如果另一个线程回调到您的 VB 代码,您将无法执行任何调用运行时的操作,例如访问字符串或对象。

有一些方法可以解决其中一些问题,但我认为我们首先需要了解更多信息。

Who's calling back to whom? Show us a little code.

The IDE can mask real problems, so just being able to run there is no guarantee that what you're doing is supported.

One common problem with callbacks is that VB6's runtime is not thread-safe, so if another thread is calling back into your VB code, you can't do anything that will invoke the runtime -- like access strings or objects.

There are ways around some of these issues, but I think we need to know more first.

还在原地等你 2024-08-06 12:28:08

代码是否从与 IDE 相同的位置运行? 可能是引用问题,需要重新注册DLL。

部署包应确保您已安装所有内容。

Is the code being run from the same location as the IDE? Likely it is a reference problem, and you need to re-register the DLL.

A deployment package should make sure you have everything installed.

回眸一遍 2024-08-06 12:28:08

有几个问题:

  1. 可执行文件是在开发时的同一台 PC 上还是不同的 PC 上?
  2. 该文件是否使用清单文件? 如果是这样,mainfest 会调用 XP 主题吗?
  3. 另外,如果使用清单,清单是否对 OCX 文件使用 SXS?

A few questions:

  1. Is the executable on the same PC as it was developed, or a different one?
  2. Does the file use a manifest file? If so, does mainfest call XP themes?
  3. Also, if using manifest, does manifest use SXS for OCX files?
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文