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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

More COM Interop- c# client holding onto unmanaged interface

Status
Not open for further replies.

Pyramus

Programmer
Dec 19, 2001
237
GB
My C# client is successfully loading an unmanaged COM server and calling a method- however it is clearly holding onto the interface after calling the method.

I have come to this conclusion because the COM server process is not terminating. When the c# client does not use the server, it terminates fine.

SO basically- is there a way in c# to force the client to release a COM interface?
 
Don't know if you are still looking for this, but look into the

System.Runtime.InteropServices.Marshal.ReleaseComObject

method. Basically, you can use it to manually decrease the references to the com interface. But because of the non-deterministic nature of the GC, I've found that if I have to be sure the interface actually gets released, I have to call a GC.Collect() after the Marshal.Release... call. Expensive, but seems to work.

HTH,

B.J.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top