PRB: COM+ Instance Count Does Not Decrease When Called from .NET Application

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.
This behavior is by design.
For more information, browse to the following Microsoft Developer Network (MSDN) Web sites:
Microsoft .NET/COM Migration and Interoperability

Article ID: 305823 - Last Review: 02/28/2014 04:29:37 - Revision: 4.3

Microsoft Enterprise Services (included with the .NET Framework) 1.0, Microsoft COM+ 1.5, Microsoft COM+ 1.0, Microsoft Transaction Services 2.0

  • kbnosurvey kbarchive kbprb kbsysadmin KB305823