Each time a COM reference is returned from unmanaged code, the reference count in the runtime callable wrapper is incremented. You could release /all/ refrences from managed code by calling ReleaseComObject in a loop until the returned count was zero.
The situations in which it's reasonable and safe to do this are pretty limited, however. The purpose of the reference count is to /avoid/ the COM object being released until all it's clients have indicated they no longer need it. Ideally, each object that acquires a reference should release the count once. I would only release all the references in the way described in a situation like a cleanup method prior to shutdown. Charlie Poole [EMAIL PROTECTED] > -----Original Message----- > From: Moderated discussion of advanced .NET topics. > [mailto:[EMAIL PROTECTED] Behalf Of Johnny Chung > Sent: Monday, July 07, 2003 11:49 PM > To: [EMAIL PROTECTED] > Subject: [ADVANCED-DOTNET] ReleaseCOMObject from Managed code > > > I read a short article on "why not to use ReleaseComObject" method on > the Chris Brume's web log. However, it started by saying that the use of > ReleaseCOMObject will release all refcounts at once, then it started > explaining the method returns the number of refcounts and how > application code should call ReleaseComObject until the method returns > 0. I am confused as to whether to use the method or not. Can someone > please explain about releaseComObject method? > > > > Cheers > > Johnny Chung > > > >
