views:

84

answers:

2

When you look at a GUID values item in the watch window you do not see the value of the item, when you expand the item you just see “Empty” this is very misleading!

You have to add “ToString()” to the value to see something useful.

So how do I get Visual Studio to add the “ToString()” it’s self?


I am using VB.NET if it make a difference.

+3  A: 

Take a look here: Visualizing GUIDs in the Visual Studio 2008 debugger


Edit by Ian

Thanks that worked well, however I had to change

<Assembly: DebuggerDisplay("{ToString}", Target:=GetType(Guid))> 

to

<Assembly: DebuggerDisplay("{ToString()}", Target:=GetType(Guid))>

so it also worked from C#

Rubens Farias
+2  A: 

When i add a guid to the watch window, it shows its value without having to expand it (the ToString() is automatically used).

How are you creating your guid? If you are using

Guid x = new Guid();

then yes, it will be an "empty" guid. If you use

Guid x = Guid.NewGuid();

then you will see that it has a value.

slugster
yeah, same here. Not sure if Ian is programming in VB.NET - in C# for sure, I do see the contents of a GUID property or field just fine in the Debug watch window
marc_s
I was wondering the same a while ago. Why my guids were all zeros, hehe. `Guid.NewGuid()` is the correct way to get a new Guid :)
Svish
That explains why I did not remember it as a problem; I have just started a new job when most of the code is in VB.NET rather than C#
Ian Ringrose