Terminate Event Not Firing
Hi,
I've written a small app which consists of a form in a standard exe and a class created in an ActiveX Dll. Unfortunately, I have to use circular references between objects, which has the nasty habit of keeping out of reference objects alive until the application ends.
I can live with this, except I need to get the class_terminate event when the application exits.... the plot thickens.
When running inside the IDE, the class terminate event is fired for each object when the form is closed and the application exits normally. This is expected. The problem happens when the application is compiled. The class_terminate event does not fire for the orphaned objects when compiled.
The “end” keyword is not used anywhere in the program and as far as I can see the program is exiting normally when the startup form is closed.
Oh, yeah, if the class is created as part of the standard exe, terminate events fire as normal, even when it’s compiled. I only seem to have the problem when the class if contained in an external dll.
I’m using VB6 Sp5 on Win 2000 Sp2, but first noticed it on VB6 SP2 on NT4 sp6.
I appreciate any help anyone can give me on this…
Cheers,
Trev.
Difference between IDE mode and EXE
when running under IDE mode, your process and thread are does of the VB.EXE and all forms, controls and classes (includeing DLLs) are loaded into it's address space.
that means, in many temms, that you don't realy run a VB program of tour own but only interpretate it and run the VB.EXE code
that causes some problems:
DLLS are loaded on-demand by VB.EXE, unlike in your EXE when they are loaded in the begining of the application. same with unload DLLs, so VB.EXE performs an explicit unload of classes and DLLs when "terminateing" your applictaion.
when useing circular refernces uncarefully, UserControls mite stay loaded (in VB.EXE itself) after "Exit" in IDE mode.
hooking thread-messages (like QuitMessage) actualy hooks the VB.EXE main thread under IDE mode. so the hook callbacks will not be called when you "Exit". don't use QuitMessage-hook in palce of Terminate_event when you run it under IDE.
shortly, all behaveore of Load, Unload, Cleanups etc. is different when runing IDE mode.