System.Runtime.InteropServices.Marshal.IsComObject Method

Indicates whether a specified object represents a COM object.

Syntax

public static bool IsComObject (object o)

Parameters

o
The object to check.

Returns

true if the o parameter is a COM type; otherwise, false.

Remarks

Marshal.IsComObject(object) returns true if the class type of the instance is attributed with System.Runtime.InteropServices.ComImportAttribute or if it derives directly or indirectly from a class attributed with System.Runtime.InteropServices.ComImportAttribute. The Tlbimp.exe (Type Library Importer) tool applies this attribute for you when it imports a type library.

Two other methods also determine whether a specified object represents a COM object, but the requirements for returning true differ from this method's requirements. Type.IsImport returns true if the class (or interface) is attributed with System.Runtime.InteropServices.ComImportAttribute directly; it does not return true for derived types. RegistrationServices.TypeRepresentsComType(Type) returns true if the type is attributed with System.Runtime.InteropServices.ComImportAttribute or derives from a type with the same GUID.

Requirements

Namespace: System.Runtime.InteropServices
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0