System.Runtime.InteropServices.InterfaceTypeAttribute Class

Indicates whether a managed interface is dual, dispatch-only, or IUnknown -only when exposed to COM.

See Also: InterfaceTypeAttribute Members


[System.AttributeUsage(System.AttributeTargets.Interface, Inherited=false)]
public sealed class InterfaceTypeAttribute : Attribute


You can apply this attribute to interfaces.

By default, the [<topic://cpgrftypelibraryExportertlbexpexe>] exposes a managed interface to COM as a dual interface, giving you the flexibility of late binding or the performance of early binding. The System.Runtime.InteropServices.ComInterfaceType enumeration enables you to override the default behavior and specify late binding only or early binding only. For example, you can apply InterfaceType (ComInterfaceType.InterfaceIsIDispatch) to an interface to produce metadata to restrict callers to late binding only. Although interfaces that derive from the IDispatch interface are often dual, the InterfaceIsIDispatch enumeration member allows only late-bound calls to the interface methods. This attribute has no effect on the managed view of the interface. For additional information on how interfaces are exposed to COM, see [<topic://cpcontlbexptypeconversion>].

The [<topic://cpgrftypelibraryImportertlbimpexe>] also applies this attribute to imported, nondual interfaces; it applies the appropriate enumeration member to indicate that the interface is dispatch-only or IUnknown -only.


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