ActiveX Unload Windows Error
Hello,
I'm developing a large application which loads OCX ActiveX controls dynamically when the OCX file are found in a specific directory using the Control.Add method. The controls are placed on a form which is referenced in a array.
VB Code:
Public Type tpModule
oModule As frmMod
ModuleName As String
ModuleFullName As String
End Type
Public oMod() As tpModule
For example Mod(i).oModule references to a form (frmMod) which contains the dynamically loaded OCX.
The application uses some extra DLL's (also ActiveX) which contains methods and functions to access the database and another DLL contains a reusable Search dialog.
The reference of this database DLL (variable: DB) is created in the main framework and forwarded to the usercontrols via a method (called SetDBControl)
When the whole application is unloaded it sets the DB variable to Nothing, and unloads all forms in the Mod() array. The problem is that when the app is finished, I get a Windows Crash error message which asks me if I want to send a message to Microsoft.
After clicking this away, I get a Instruction on 0x001b48cf points to memory adress 0x003d5ffc5. The read of write processes (write) on this memory block have failed. Or someting in this manner...
My though is that the controls don't unload in time when the application closes. That way, the control tries to access the memory or write someting to the memory but the application already finished whith this memory block? Am I in the right direction? Can anyone point me to some solution how to fix this? How to unload all control clean and exit the application?
Does anyone have another theory?
Thank you very much for your time...