Type.IsCOMObject Property
Gets a value indicating whether the Type is a COM object.
[Visual Basic] Public ReadOnly Property IsCOMObject As Boolean [C#] public bool IsCOMObject {get;} [C++] public: __property bool get_IsCOMObject(); [JScript] public function get IsCOMObject() : Boolean;
Property Value
true if the Type is a COM object; otherwise, false.
Remarks
This method returns false for COM interfaces because they are not objects. COM interfaces can be implemented by Microsoft .NET Framework objects.
You can also load a COM class and get a Type object for that COM class by using the Type Library Importer (Tlbimp.exe) tool.
Example
[Visual Basic, C#, C++] The following example shows a use of the IsCOMObject property.
[Visual Basic] <ComVisible(False)> _ Public Class MarshalWrapper Public Sub MarshalMethod() Dim obj As [Object] obj = Marshal.GetActiveObject("Excel.Application") If Marshal.IsComObject(obj) Then Marshal.ReleaseComObject(obj) End If End Sub 'MarshalMethod End Class 'MarshalWrapper [C#] public class MarshalWrapper { public void MarshalMethod() { Object obj; obj = Marshal.GetActiveObject("Excel.Application"); if (Marshal.IsComObject(obj)) { Marshal.ReleaseComObject(obj); } } } [C++] public __gc class MarshalWrapper { public: void MarshalMethod() { Object* obj; obj = Marshal::GetActiveObject(S"Excel.Application"); if (Marshal::IsComObject(obj)) { Marshal::ReleaseComObject(obj); } } };
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework
See Also
Type Class | Type Members | System Namespace | IsCOMObjectImpl