Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ COM
... how can the client release its reference?
 
Calling Release() on the pointer does not work. I think I got an RPC_E_DISCONNECTED error. I had this problem about five years ago and it was never fully fixed and the problem came up again in conversation and I was wondering if anyone has had experience with this.
 
Thanks.
Posted 9-Nov-12 9:23am
Comments
manoranjan at 12-Nov-12 0:01am
   
Can you please be more specific? IUnknown->Release() returns a reference count and not HRESULT.
 
In any case you shouldn't bother releasing a crashed COM server. AddRef/Release mechanism is used to unload a COM server from memory. A crashed server is already unloaded (by the OS).
Michael Bergman at 12-Nov-12 0:42am
   
You are, of course, right about Release(). I knew that but I must have conflated that with another call that I made to access the object.
 
I don't think I can be more specific as this was five years ago, I but I think I can describe the problem a little more thoroughly.
 
There are three components:
1. An ActiveX control hosted in an application.
2. An Out-of-Proc COM Server which does work for the ActiveX control. The COM Server instantiates when call upon by the ActiveX control and closes when the ActiveX control closes with its host application.
3. Another Out-of-Proc COM Server which does work for the first COM Server. It is instantiated when the first COM Server calls it and it closes when it is released.
 

The problem is that the second COM Server crashes. We couldn't fix it because it was using propriatary API that we needed and that API was extremely buggy. Needless to say, it was a Microsoft API so we couldn't get them to fix it.
 
So what happens is:
ActiveX calls Server 1, gets a reference to Server 1
Server 1 call Server 2, Server 2 gets a reference to Server 1
Server 2 crashes,
Server 1 re-instantiates Server 2
Server 1 call Server 2 and get what it needs, Server 2 gets a reference to Server 1
Server 1 closes Server 2, Server 2 releases its reference to Server 1.
ActiveX host closes ActiveX control and releases its reference to Server 1
Server 1 does not close
 
Server 1 does not close because it still thinks the Server 2 which crashed still has a reference to it.
 
We were able to work around this problem, but it was a kludge. I was just wondering if anyone else had this particular problem (which I should have written more clearly the first time) and if they were able to resolve it.
 
Thanks for responding

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 380
1 CPallini 375
2 BillWoodruff 314
3 George Jonsson 279
4 OriginalGriff 227
0 OriginalGriff 5,030
1 CPallini 4,225
2 Sergey Alexandrovich Kryukov 3,604
3 George Jonsson 2,831
4 Gihan Liyanage 2,386


Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 9 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100