PRB: OLE Servers Don't Unload When Last Object Set to Nothing (137031)
The information in this article applies to:
- Microsoft Visual Basic Standard Edition, 32-bit, for Windows 4.0
- Microsoft Visual Basic Professional Edition, 16-bit, for Windows 4.0
- Microsoft Visual Basic Professional Edition, 32-bit, for Windows 4.0
- Microsoft Visual Basic Enterprise Edition, 16-bit, for Windows 4.0
- Microsoft Visual Basic Enterprise Edition, 32-bit, for Windows 4.0
This article was previously published under Q137031 SYMPTOMS
An OLE Automation server created with Visual Basic fails to unload from
memory when the last instance of the object is destroyed.
CAUSE
A Visual Basic client can destroy the last instance of a Visual Basic OLE
server it created by: - Setting it to Nothing (the preferred method).
- Shutting down by unloading the last form (acceptable, but not as good).
- Ending the program by using the End statement (this is not recommended;
it can cause problems because the QueryUnload, Unload, and Terminate
events don't fire)
If the OLE server has a non-visible form still loaded when the last
instance is destroyed, the OLE server is not destroyed. This is usually
handled in the Terminate event of the OLE server.
RESOLUTION
OLE servers are responsible for cleaning up any objects that they create or
load. When an OLE server is unloaded, the Terminate event will be fired.
This is where code should be located to unload any forms that the OLE
server has in memory.
STATUS
This behavior is by design.
Modification Type: | Major | Last Reviewed: | 12/9/2003 |
---|
Keywords: | kbprb KB137031 |
---|
|