O'Reilly logo

VB.NET Language in a Nutshell, Second Edition by Steven Roman PhD, Paul Lomax, Ron Petrusha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

Guid Attribute

Class

System.Runtime.InteropServices.GuidAttribute

Applies to

Assembly, Class, Delegate, Enum, Interface, Struct

Description

Assigns an explicit Globally Unique Identifier (GUID) to a program element when an automatically generated GUID is undesirable. The <Guid> attribute is used for COM interop. A GUID can be generated by a utility named guidgen.exe .

The major reason for explicitly assigning a GUID to a program element, rather than allowing Visual Studio to do it automatically, is to ensure that it remains constant over successive recompilations of the source code. Because COM uses GUIDs to identify program elements, inadvertently changing a GUID typically causes COM to fail to recognize a component. For example, Visual Studio automatically adds the <Guid> attribute to each AssemblyInfo.vb file to ensure that, should a type library be generated for a particular project, its library identifier (or LibID) will remain unchanged when the project is recompiled.

Constructor

New(guid)
guid (String)

The GUID to be assigned to the program element.

Properties

Value (String)

Read-only. Returns the GUID of the program element.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required