Re: ATL COM Server exits when client exits

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Ben Rush (kwendex_at_yahoo.com)
Date: 07/06/04


Date: Tue, 06 Jul 2004 01:09:33 -0500

Ganesh,

>Alternatively, I was wondering if I could create a dummy client
>which will make a connection to the COM server and will always be
>running "holding" the COM server from exiting. I know it is possible,
>but would this be a good programming practice.

As far as the second part of your question, is it a "good programming
practice", I'm not sure. But the functionality you speak of is how COM
cross-apartment communication occurs. When a remote activation request
for a COM object is made through ORPC channels, the COM essentially
connects with the correct COM apartment to call CoMarshalInterface on
the requested interface (once it has been fully brought to life). This
API returns what is called a stub manager which holds onto the object
through IUnknown. The stub manager increments the ref count by 1 when
it holds onto the remoted object, but maintains an internal reference
count for each outstanding outer-apartment reference. When it detects
all references are gone, it terminates and decrements its counter by
1, thereby removing itself and the object (given that it has no other
outstanding references). All of this is pre-XPSP2.

What all of this means is that COM already does this - so its
possible. Potentially one could recommend to tred with caution,
though, as doing something to short-circuit the COM's garbage
collection capabilities could result in some very hard-to-debug code.

One has to ask, though, how are you going to make sure that the
object holding onto your object isn't deleted? Are you going to
implement it as a service?

>Alternatively, can I
>make the COM server itself make some kind of a virtual connection to
>itself so that the reference count is always greater than zero
>preventing the application from exiting.
> Thanks in advance for your valuable time.
>

This sounds like a more confusing version of the previous idea you
had. Perhaps I'm missing something?

>> Ben Rush
>> http://my.mindvision.com/~ben/spoutlet/spoutings.html

Ben Rush
http://my.mindvision.com/~ben/spoutlet/spoutings.html



Relevant Pages

  • Re: FWCTool Reporting HTTP Error 403
    ... but when I posted my initial message I didn't reference any KB ... suggesting was completed when we first set up the server. ... We have been running ISA 2004 SP2 very successfully for months. ... I ran the FWCTool to troubleshoot the connection and everything reports ...
    (microsoft.public.isa.clients)
  • error: an exception of type: {System.InvalidOperationException} occurred
    ... so that it's available to me whenever I reference the class: ... I do a quick watch on 'Conn' and pretty much everything looks ... the connection is there, the connectionstring is correct. ... good - on the server version, ...
    (microsoft.public.dotnet.framework.aspnet)
  • error: an exception of type: {System.InvalidOperationException} occurred
    ... so that it's available to me whenever I reference the class: ... I do a quick watch on 'Conn' and pretty much everything looks ... the connection is there, the connectionstring is correct. ... good - on the server version, ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: RDB limitations: from Jimmy Gavan
    ... Your DBI QUESTION: ... Bearing in mind no compiler to reference or even test my thoughts, ... The unique Id is used as a DB connection ... move SQLSTATE to MOST-SQLSTATE ...
    (comp.lang.cobol)
  • Re: 4-way Opteron vs. Xeon-IBM X3 architecture
    ... >>>The point here is that the issue concerns both speed AND capacity. ... >As to the reference, the message header points right back in this thread, ... >>>As you may suspect, I read plenty about memory systems, and I would ... >>>from the enthusiast market and assumed that it would work in the server ...
    (comp.sys.ibm.pc.hardware.chips)