COMClass Attribute

   
COMClass Attribute

Class

Microsoft.VisualBasic.COMClassAttribute

Applies to

Class

Description

Adds metadata that allows a .NET class to be exposed as a COM object. You can supply the attribute with a class identifier, an interface identifier, and an event identifier. All are globally unique identifiers (GUIDs) that can be generated either by using the guidgen .exe utility or automatically by using the COM Class Wizard. They ensure that the COM component retains the same GUIDs when it is recompiled.

Constructor

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

The class identifier (CLSID) that will uniquely identify the COM class

interfaceID (String)

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

eventID (String)

The event identifier that uniquely identifies an event

Properties

ClassID (String)

Read-only. Provides the class identifier (CLSID) that uniquely identifies a COM class. Its value is set by the classID parameter of the class constructor.

EventID (String)

Read-only. Provides the GUID that uniquely identifies an event. Its value is set by the eventID parameter of the class constructor.

InterfaceID (String)

Read-only. Provides the interface identifier (IID) that uniquely identifies a COM interface. Its value is set by the interfaceID parameter of the class constructor.

InterfaceShadows (Boolean)

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

Example

The example defines a simple class named CContact that includes the <ComClass> attribute. Note that the GUIDs are in standard registry format except for the beginning and closing brace .

 <ComClass(CContact.ClassID, CContact.InterfaceID, CContact.EventID), _ Description("COM Contact Class")> Public Class CContact 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 sName As String Private sCity, sState, sZip As String Public Property Name(  ) As String Get    Return sName End Get Set(ByVal Value As String)    sName = Value End Set End Property Public Sub New(  )    MyBase.New(  ) End Sub End Class 
   


VB.Net Language in a Nutshell
VB.NET Language in a Nutshell
ISBN: B00006L54Q
EAN: N/A
Year: 2002
Pages: 503

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