Identifies the type of class interface that is generated for a class.
Assembly: mscorlib (in mscorlib.dll)
Indicates that the class only supports late binding for COM clients. A dispinterface for the class is automatically exposed to COM clients on request. The type library produced by Tlbexp.exe (Type Library Exporter) does not contain type information for the dispinterface in order to prevent clients from caching the DISPIDs of the interface. The dispinterface does not exhibit the versioning problems described in ClassInterfaceAttribute because clients can only late-bind to the interface.
Indicates that a dual class interface is automatically generated for the class and exposed to COM. Type information is produced for the class interface and published in the type library. Using AutoDual is strongly discouraged because of the versioning limitations described in ClassInterfaceAttribute.
Indicates that no class interface is generated for the class. If no interfaces are implemented explicitly, the class can only provide late-bound access through the IDispatch interface. This is the recommended setting for ClassInterfaceAttribute. Using ClassInterfaceType.None is the only way to expose functionality through interfaces implemented explicitly by the class.
This example shows how to apply the ClassInterfaceAttribute to a type, setting the . Classes defined this way can be used from unmanaged COM.
Imports System Imports System.Runtime.InteropServices ' Have the CLR expose a class interface (derived from IDispatch) for this type. ' COM clients can call the members of this class using the Invoke method from the IDispatch interface. <ClassInterface(ClassInterfaceType.AutoDispatch)> _ Public Class AClassUsableViaCOM Public Sub New() End Sub Public Function Add(ByVal x As Int32, ByVal y As Int32) As Int32 Return x + y End Function End Class ' The CLR does not expose a class interface for this type. ' COM clients can call the members of this class using the methods from the IComparable interface. <ClassInterface(ClassInterfaceType.None)> _ Public Class AnotherClassUsableViaCOM Implements IComparable Public Sub New() End Sub Function CompareTo(ByVal o As [Object]) As Int32 Implements IComparable.CompareTo Return 0 End Function 'IComparable.CompareTo End Class
Available since 8
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Available since 8.1