tleichen
February 4th, 2000, 03:59 PM
Periodically I have VB crash when I call a C++ DLL in a VB program. This only occurs in the VB IDE and not when the program is made into a .exe. Is this just a bug in VB?
|
Click to See Complete Forum and Search --> : VB and DLLs tleichen February 4th, 2000, 03:59 PM Periodically I have VB crash when I call a C++ DLL in a VB program. This only occurs in the VB IDE and not when the program is made into a .exe. Is this just a bug in VB? March 26th, 2000, 11:00 AM You get problems like this using the cool API functions that use callbacks. Basically, a callback is a path for a windows procedure (such as Form_Click equivalent for the desktop etc.) so that a certain sub in your code gets called also. If you say what function it is, maybe i could help, but otherwise there are load of things that it could be. One ofv the main things could be that WindowsAPI always insists on having the same thing passed to it that is specifies (as in an integer to a long is not allowed or a ByRef to a ByVal is not either). Sometimes VB does not like some things (like multithreading - yes it is *just* possible). So it will crash the IDE but will work fine outside of it. Hope its helped you! Kris with a K Tahbaza April 3rd, 2000, 11:32 PM You must be careful when calling C++ from VB in the IDE. Access violations are easy to trigger because of several reasons. One is callbacks. Some C++ functions (like SetTimer) require you to pass the memory location (with AddressOf) to the function so that the routine may call your code directly. If you End or press the Stop button your temporary runtime memory is cleared abruptly and the C++ function calls back to a function that no longer exists, thus causing a memory access violation and the death of your IDE. (Moral : save frequently) Another common cause of your problem is passing the wrong data type or incorrect buffer length to a C++ routine. C++ from VB is fragile in the IDE... Good luck == Ali R. Tahbaz, MCSD ========================== "Whether you think that you can, or that you can't, you are usually right." --Henry Ford vbfingers April 7th, 2000, 11:24 AM An addendum to "TAHBAZA"'s 2nd paragrah response... First Shorts in VC++ are an Integer in VB Ints in VC++ are a Long in VB. Secondly: YOU MUST pass the same string length between a DLL and VB and you MUST pass all strings by 'BYVAL', OR things may start to happen. I learned the very hard way. The DLL File that I made is a non-MFC one. And I used 'WINAPI' stuff. VBFingers. codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |