BlackWaspTM

This web site uses cookies. By using the site you accept the cookie policy.This message is for compliance with the UK ICO law.

Visual Studio
VS 2005+

Creating GUIDs in Visual Studio

Globally unique identifiers (GUIDs) have many uses for software developers. When a single unique ID is required, one can be randomly generated using Visual Studio's Create GUID command. This article describes the required steps to achieve this.

Creating GUIDs

Globally unique identifers (GUIDs) are often used to specify unique identities for data in distributed or replicated systems to avoid duplicated IDs being generated. They are also used within the Windows operating system to identify items in the registry, to apply unique IDs to .NET assemblies and for many other purposes. It is a simple task to generate new GUIDs using a language such as C#. However, sometimes you will wish to create a new GUID without writing code. To do so, you can use Visual Studio's Create GUID tool.

To display the Create GUID window, select "Create GUID" from the Tools menu within Visual Studio. The dialog box shown below should appear. This dialog is actually the main window for a tool named "guidgen.exe". If this executable has not been installed, the option will be unavailable. It is also possible that the menu item is hidden. This depends upon the option selected when Visual Studio was first executed. In this situation you can add "guidgen.exe" as an external tool.

Visual Studio Create GUID Dialog Box

The dialog box shows four options for the format of GUID that you wish to create. The last option produces a simple GUID whilst options one, two and three include code and comments that can be pasted into your source code. To generate a new GUID, click the New GUID button. To use the generated value, choose your preferred style from the list and click the Copy button. You can then paste the code into any text editor.

29 November 2009