CoClassAttribute Class
Assembly: mscorlib (in mscorlib.dll)
'Declaration <ComVisibleAttribute(True)> _ <AttributeUsageAttribute(AttributeTargets.Interface, Inherited:=False)> _ Public NotInheritable Class CoClassAttribute Inherits Attribute 'Usage Dim instance As CoClassAttribute
/** @attribute ComVisibleAttribute(true) */ /** @attribute AttributeUsageAttribute(AttributeTargets.Interface, Inherited=false) */ public final class CoClassAttribute extends Attribute
ComVisibleAttribute(true) AttributeUsageAttribute(AttributeTargets.Interface, Inherited=false) public final class CoClassAttribute extends Attribute
You can apply this attribute to coclass interfaces, although the Type Library Importer (Tlbimp.exe) typically applies it for you when it imports a type library.
When Tlbimp.exe imports a coclass, it produces a managed class and an interface to represent the coclass. The coclass interface has the same interface identifier (IID) as the default interface of the original coclass. The imported coclass interface also retains the name of the coclass. Tlbimp.exe appends the original coclass name with "class" to identify the imported class.
You rarely apply this attribute. However, if plan to write source code that produces metadata that closely simulates metadata produced by Tlbimp.exe, you should create a coclass interface for each coclass. Use the name of the original coclass to name the coclass interface and derive it from the default interface. In addition to the CoClassAttribute, you must also apply the System.Runtime.InteropServices.ComImportAttribute and System.Runtime.InteropServices.GuidAttribute to the coclass interface. For additional information about how Tlbimp.exe imports interfaces and coclasses from a type library, see Imported Type Conversion.
Windows 98, Windows 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 .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.