Groups | Blog | Home
all groups > dotnet interop > march 2005 >

dotnet interop : Reference Counting


Howard Swope
3/16/2005 4:33:47 PM
I have a managed application that creates an instance of an out or process
com server. After releaseing any references to the server, the server
lockcount will not go to zero. Only after exiting the managed application
will the out of process server lock count go to zero and the process
terminate.

Is interop holding on to a reference somewhere and is there a way to force
it to release it?

--
Howard Swope [howardsnewsATspitzincDOTcom]
Software Engineer
Spitz, Inc [http://www.spitzinc.com]

Scott M.
3/16/2005 5:09:18 PM
Are you calling:
System.Runtime.InteropServices.Marshal.ReleaseComObject(comObj) in addition
to removing the managed references to the com object?




[quoted text, click to view]

Phil Wilson
3/16/2005 6:44:08 PM
One of the things that usually happens in these situations is that reference
counts are cached to avoid the ping-pong situation. If the references were
completely accurate and not cached, you could easily get a situation where
the ref count goes to zero, the server process goes away, and 1 second later
the server needs re-initiating because you created another object. That
doesn't solve your problem, but hopefully it helps explain why you're not
here asking a question about your out-of-process server going up and down
all the time.
--
Phil Wilson
[Microsoft MVP-Windows Installer]
[quoted text, click to view]

Sean Hederman
3/16/2005 11:46:42 PM
[quoted text, click to view]

Difficult to tell without looking at the code, but have a look at
System.Runtime.InteropServices.Marshal.ReleaseComObject to decrement the
reference count manually.

[quoted text, click to view]

Howard Swope
3/17/2005 9:44:18 AM
System.Runtime.InteropServices.Marshal.ReleaseComObject was exactly what
was needed.

Thanks.

[quoted text, click to view]

AddThis Social Bookmark Button