Article ID: 305823 - View products that this article applies to.
This article was previously published under Q305823
This article has been archived. It is offered "as is" and will no longer be updated.
When you call a COM+ or Microsoft Transaction Server (MTS) component from a .NET application, the object activates in the COM+ or MTS-hosted environment, but when the call completes, the object count does not decrease immediately. This is true even if the object is explicitly set to nothing (Visual Basic .NET) or null (C#) in the .NET client code.
This behavior can occur because the .NET application actually contains a reference to a wrapper, known as a runtime callable wrapper (RCW), which is responsible for managing reference counts on the COM+ or MTS component. This RCW is subject to .NET garbage collection semantics. Only when the RCW is "garbage collected" does it call the final release on the Component Object Model (COM) object. Garbage collection occurs only under memory pressure. Therefore, under simple test conditions, it is possible to observe an object activation remain alive indefinitely in Status view in COM+ Explorer.
To resolve this issue, explicitly release the COM object by calling the following method on the RCW from your .NET application:
This method call forces the wrapper to release the reference. The wrapper is freed up when garbage collection occurs.
For more information, browse to the following Microsoft Developer Network (MSDN) Web sites:
Introduction to COM Interop
Microsoft .NET/COM Migration and Interoperability
Article ID: 305823 - Last Review: February 28, 2014 - Revision: 4.3
Contact us for more help
Connect with Answer Desk for expert help.