This article is also available on the
Microsoft TechNet Wiki
.
A globally unique identifier or GUID is an id that is exclusive throughout the globe. They are usually 128 bits long and are shown in hexadecimal groups separated by hyphens.
Within Visual Studio there exists a standalone tool (guidgen.exe) that allows developers to create GUIDs in a specific format. Creating GUIDs in code is easy enough but perhaps you need to generate one (for a constant or while unit testing) without running your code. This tool can help with that.
Creating GUIDs
To find the tool, open Visual Studio and click
Tools
>
Create GUID
.
The Create GUID window will appear.
There are seven different GUID formats to choose from. As you move through the types, the Result window will display what the GUID value will look like.
If you want a different GUID, click the
New GUID
button.
Once you are happy with your result, click the
Copy
button to save it to the Clipboard. You can then paste it to your desired locale.
Click
Exit
to close the dialog window.
Troubleshooting
If the tool does not appear under the Tools menu, click
Tools
>
External Tools
(see top image). It may be that the tool was not registered correctly within the IDE. Using the External Tools window, we can add a reference to guidgen.exe.
Click the
Add
button. A new tool will be added to the Menu contents.
Fill in the fields like so:
Enter a Title of
Create &GUID
. The ampersand will create a hotkey using the letter G.
For the Command field, browse to the Tools folder of your current Visual Studio install and find guidgen.exe. This location will typically be
%Installation Path%\Microsoft Visual Studio {Version Number}\Common7\Tools\guidgen.exe
. For Visual Studio 2015, the full path will look like this:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools
.
NOTE:
You can also double click the exe here to run it. You will see the same Create GUID UI as above.
For the Initial directory, use the guidgen.exe root folder or
%Installation Path%\Microsoft Visual Studio {Version Number}\Common7\Tools\
When you are done, your entry should look something like this:
Click
OK
.
Your tool should now appear in the Tools menu.
See Also
Create GUID (guidgen.exe)
Related
Enter your email address to follow this blog and receive notifications of new posts by email.
Email Address: