Marshal.FinalReleaseComObject(Object) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Releases all references to a Runtime Callable Wrapper (RCW) by setting its reference count to 0.
public:
static int FinalReleaseComObject(System::Object ^ o);
[System.Security.SecurityCritical]
public static int FinalReleaseComObject (object o);
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public static int FinalReleaseComObject (object o);
public static int FinalReleaseComObject (object o);
[<System.Security.SecurityCritical>]
static member FinalReleaseComObject : obj -> int
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
static member FinalReleaseComObject : obj -> int
static member FinalReleaseComObject : obj -> int
Public Shared Function FinalReleaseComObject (o As Object) As Integer
Parameters
- o
- Object
The RCW to be released.
Returns
The new value of the reference count of the RCW associated with the o
parameter, which is 0 (zero) if the release is successful.
- Attributes
Exceptions
o
is not a valid COM object.
o
is null
.
Remarks
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.
Applies to
See also
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈