FinalReleaseComObject Method
Collapse the table of content
Expand the table of content

Marshal.FinalReleaseComObject Method (Object)


Releases all references to a Runtime Callable Wrapper (RCW) by setting its reference count to 0.

Namespace:   System.Runtime.InteropServices
Assembly:  mscorlib (in mscorlib.dll)

public static int FinalReleaseComObject(
	object o


Type: System.Object

The RCW to be released.

Return Value

Type: System.Int32

The new value of the reference count of the RCW associated with the oparameter, which is 0 (zero) if the release is successful.

Exception Condition

o is not a valid COM object.


o is null.

The FinalReleaseComObject method releases the managed reference to a COM object. Calling this method is equivalent to calling the ReleaseComObject method in a loop until it returns 0 (zero).

When the reference count on the COM object becomes 0, the COM object is usually freed, although this depends on the COM object's implementation and is beyond the control of the runtime. However, the RCW can still exist, waiting to be garbage-collected.

The COM object cannot be used after it has been separated from its underlying RCW. If you try to call a method on the RCW after its reference count becomes 0, a InvalidComObjectException will be thrown.


requires full trust for the immediate caller. This member cannot be used by partially trusted or transparent code.

Universal Windows Platform
Available since 4.5
.NET Framework
Available since 2.0
Portable Class Library
Supported in: portable .NET platforms
Windows Phone Silverlight
Available since 8.0
Windows Phone
Available since 8.1
Return to top
© 2015 Microsoft