[英]How do I see the value of a GUID in the Visual Studio 2008 debugger?
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! 当您在监视窗口中查看GUID值项目时,您看不到该项目的值,而展开该项目时,您只会看到“ Empty ”( 空 ),这非常容易引起误解!
You have to add “ToString()” to the value to see something useful. 您必须在值中添加“ ToString()”才能看到有用的东西。
So how do I get Visual Studio to add the “ToString()” it's self? 那么,如何使Visual Studio自行添加“ ToString()”呢?
I am using VB.NET if it make a difference. 我正在使用VB.NET,如果有所作为。
Take a look here: Visualizing GUIDs in the Visual Studio 2008 debugger 在这里看看: 在Visual Studio 2008调试器中可视化GUID
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# 所以它也可以在C#中工作
When i add a guid to the watch window, it shows its value without having to expand it (the ToString() is automatically used). 当我将GUID添加到监视窗口时,它无需扩展即可显示其值(自动使用ToString())。
How are you creating your guid? 您如何创建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. 那么您将看到它具有价值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.