
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
178
|
Chapter 3: Classes and Structures
MsgBox (x.ToString( ))
MsgBox (x.GetHashCode( ))
End Sub
• It is a good idea to explicitly state the GUIDs for any types exposed to COM cli-
ents, including any exposed interfaces, through the use of the
GuidAttribute.
This prevents Tlbexp/Regasm from creating new GUIDs every time your inter-
face changes. A new GUID is created by the Regasm tool every time you choose
the Build
➝ Rebuild Solution or Build ➝ Rebuild ProjectName menu item. These
actions cause the date/time of the module (dll or exe), as well as the version
number for your assembly, to change which, in turn, can cause a different GUID
to be calculated. A new GUID will be calculated for a rebuilt assembly even if no
code changes within that assembly. Not explicitly adding a GUID to your
exposed types will cause your registry to greatly expand during the development
stage as more new GUIDs are added to it.
• It is also a good idea to limit the visibility of your types/members through judi-
cial use of the
ComVisibleAttribute. This can prevent unauthorized use of spe-
cific types/members that could possibly corrupt data or be used to create a
security hole by malicious code.
• Exposed types should implement an interface (for example,
IFoo) that allows
you to specify exactly what members of