This documentation is archived and is not being maintained.

InterfaceTypeAttribute Class

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

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

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

You can apply this attribute to interfaces.

By default, the Type Library Exporter (Tlbexp.exe) exposes a managed interface to COM as a dual interface, giving you the flexibility of late binding or the performance of early binding. The 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 Exported Type Conversion.

The Type Library Importer (Tlbimp.exe) 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.

The following example shows how InterfaceTypeAttribute controls how the interface is exposed to COM.

using System.Runtime.InteropServices;

//Interface is exposed to COM as dual. 
interface IMyInterface1 
    //Insert code here.

//Interface is exposed to COM as IDispatch.
interface IMyInterface2 
    //Insert code here.


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0