InterfaceTypeAttribute Class
Assembly: mscorlib (in mscorlib.dll)
'Declaration <AttributeUsageAttribute(AttributeTargets.Interface, Inherited:=False)> _ <ComVisibleAttribute(True)> _ Public NotInheritable Class InterfaceTypeAttribute Inherits Attribute 'Usage Dim instance As InterfaceTypeAttribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Interface, Inherited=false) */ /** @attribute ComVisibleAttribute(true) */ public final class InterfaceTypeAttribute extends Attribute
AttributeUsageAttribute(AttributeTargets.Interface, Inherited=false) ComVisibleAttribute(true) public final class InterfaceTypeAttribute extends Attribute
Not applicable.
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.
Imports System.Runtime.InteropServices 'Interface is exposed to COM as dual. Interface IMyInterface1 'Insert code here. End Interface 'Interface is exposed to COM as IDispatch. <InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)> _ Interface IMyInterface2 'Insert code here. End Interface
import System.Runtime.InteropServices.*;
//Interface is exposed to COM as dual.
interface IMyInterface1
{
//Insert code here.
} //IMyInterface1
//Interface is exposed to COM as IDispatch.
/** @attribute InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)
*/
interface IMyInterface2
{
//Insert code here.
} //IMyInterface2
import System.Runtime.InteropServices //Interface will be exposed to COM as dual. interface IMyInterface1{ // ... } //Interface will be exposed to COM as IDispatch. public InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch) interface IMyInterface2{ // ... }
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.