Vb6 application works in the IDE but the executable crashes

删除回忆录丶 提交于 2019-12-10 15:29:47

问题


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


回答1:


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...




回答2:


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.




回答3:


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.




回答4:


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?


来源:https://stackoverflow.com/questions/1239317/vb6-application-works-in-the-ide-but-the-executable-crashes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!