Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

COM Server Warning on shutdown

Status
Not open for further replies.

Dachyon

Programmer
Nov 4, 2002
32
NZ
Hi All,
I am developing some software which consists of a main application which starts up several other programs using Automation. My problem is when the PC shuts down (without first closing my main app) I get the following message dialog :-

COM Server Warning
There are still active COM objects in this application. One or more clients may have references to these objects, so manually closing this application may cause these clients to fail.


Does anyone know how to avoid this ?

Mny Tnx.
Dachyon
 
You're probably getting that warning because you didn't first close your main app. Your main app probably still holds some references to the other programs/objects which you started up through Automation.

If you can release your main app's references to those objects, do so. If you can't, I don't think you can avoid the problem unless there's a backdoor way to quiet down COM's warnings.
 
Hi - thanks for your response...

I have tried using a callback interface to allow the COM server to call a method on the client which nulls its interface reference, thereby allowing me to shutdown the COM server nicely without raising any warnings. This works fine if I close the COM Server app manually...the problem occurs when I shutdown the PC from the Start menu.

I wish my COM server app to work the same way as MSWord or IE - you can close those apps down without having to null the interface reference in the client, and it does'nt raise any warnings...

PS. The warnings occur for both single and multi instance COM servers...
 
Would CoDisconnectObject be appropriate here?
You would probably need to handle messages WM_QUERYENDSESSION and WM_ENDSESSION. Then place the call to CoDisconnectObject in the latter message's handling implementation.
It's been a while since I worked with these, but those pointers might set you on a productive track.
 
OK, eventually found a solution to this.
I got around it by adding an OnClose callback event to the COM interface definition. The OnClose event gets triggered when the COM server application receives a WM_ENDSESSION or WM_QUERYENDSESSION message in its queue.
The client then nulls the interface reference whenever it receives the OnClose event, thereby shutting down the COM server application.
This solution avoids the COM Server Warning message described in my first POST.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top