COMClass Attribute


COMClass Attribute

Class

Microsoft.VisualBasic.COMClassAttribute

Applies To

Class

Constructor

     New([classID[, interfaceID[, eventID]]][, interfaceShadows]) 


classID (optional; String)

The class identifier (CLSID) globally unique identifier (GUID) that uniquely identifies the COM class.


interfaceID (optional; String)

The interface identifier (IID) GUID that uniquely identifies the class's default COM interface.


eventID (optional; String)

The event identifier GUID that uniquely identifies an event.


interfaceShadows (optional; Boolean)

Indicates whether the COM interface name is the same as the name of another member of the class or the base class. If omitted, the default value is False.

Properties


ClassID (String)

Read-only. Set by the classID class constructor parameter.


EventID (String)

Read-only. Set by the interfaceID class constructor parameter.


InterfaceID (String)

Read-only. Set by the eventID class constructor parameter.


InterfaceShadows (Boolean)

Indicates whether the COM interface name is the same as the name of another member of the class or the base class. Set by the interfaceShadows class constructor parameter.

Description

The <COMClass > attribute adds metadata to a class that exposes a .NET class as a COM object. You can supply the attribute with a class identifier, an interface identifier, and an event identifier. All are GUIDs that can be generated by using the guidgen.exe utility. Using this attribute ensures that the COM component retains the same GUIDs even when it is recompiled.

Example

The example defines a simple class named Contact that includes the <COMClass> attribute. The GUIDs are in standard registry format except for the absence of the opening and closing braces.

     <COMClass(Contact.ClassID, Contact.InterfaceID, Contact.EventID)> _     Public Class Contact        Friend Const ClassID As String = _           "C7BA6669-DCFB-43d6-9A74-B1BCC6EE467B"        Friend Const InterfaceID As String = _           "72663B50-6A44-46e7-83B6-F1A4F149FF5F"        Friend Const EventID As String = _           "BD2C0D5E-C0D7-4e1e-A9E8-AD29C8003D4B"        Private contactName As String        Private contactCity As String        Private contactState As String        Private contactZip As String        Public Property Name(  ) As String           Get              Return contactName           End Get           Set(ByVal value As String)              contactName = value           End Set        End Property        Public Sub New(  )           MyBase.New(  )        End Sub     End Class 

See Also

MarshalAs Attribute




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net