CoClassAttribute Class
Specifies the class identifier of a coclass imported from a type library.
For a list of all members of this type, see CoClassAttribute Members.
System.Object
System.Attribute
System.Runtime.InteropServices.CoClassAttribute
[Visual Basic] <AttributeUsage(AttributeTargets.Interface)> NotInheritable Public Class CoClassAttribute Inherits Attribute [C#] [AttributeUsage(AttributeTargets.Interface)] public sealed class CoClassAttribute : Attribute [C++] [AttributeUsage(AttributeTargets::Interface)] public __gc __sealed class CoClassAttribute : public Attribute [JScript] public AttributeUsage(AttributeTargets.Interface) class CoClassAttribute extends Attribute
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Remarks
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.
Requirements
Namespace: System.Runtime.InteropServices
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
Assembly: Mscorlib (in Mscorlib.dll)
See Also
CoClassAttribute Members | System.Runtime.InteropServices Namespace | ComImportAttribute | GuidAttribute | Type Library Importer (Tlbimp.exe)