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开发者_C百科 the “ToString()” it’s self?
I am using VB.NET if it make a difference.
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#
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.
精彩评论