为什么字典调试可视化工具在 Visual Studio 2010 中对于 Silverlight 调试不太有用?
我正在 Visual Studio 2010(我们刚刚安装)中进行调试,并尝试在快速监视窗口中查看字典。我看到了键和值,但深入研究这些显示了计数和非公共成员,非公共成员继续跟踪,我从未在字典中看到这些值。我可以运行 test.Take(10) 并查看值,但为什么我必须这样做。我没有安装 VS 2008 来进行比较,但似乎我可以更轻松地调试字典。为什么现在变成这样了?这只是我在机器上以某种方式设置的设置吗?
测试代码:
Dictionary<string, string> test = new Dictionary<string, string>();
test.Add("a", "b");
编辑: 我刚刚在控制台应用程序中尝试了相同的调试,它按预期工作。另一个项目是Silverlight 4应用程序,为什么它们不同?
编辑:来自微软连接: “这是我们的疏忽 - 我们之前已针对 Visual Studio 2008 SP1 修复了这个确切问题,但不幸的是,此修复并未移植到 Visual Studio 2010 代码库中。现在已再次修复此问题(这次是永久修复!),我们正在考虑在 VS2010 SP1 中发布此修复程序
。 项目经理 Visual Basic 和 C# 编译器”所以应该很快就会修复。
编辑:我刚刚在 SP1 中仔细检查了这一点,它工作正常。
I was debugging in Visual Studio 2010, which we just installed and trying to look at a dictionary in the quick watch window. I see Keys and Values, but drilling into those shows the Count and Non-Public members, Non-Public members continues the trail and I never see the values in the dictionary. I can run test.Take(10) and see the values, but why should I have to do that. I don't have VS 2008 installed anymore to compare, but it seems that I could debug a dictionary much easier. Why is it this way now? Is it just a setting I set somehow on my machine?
Test code:
Dictionary<string, string> test = new Dictionary<string, string>();
test.Add("a", "b");
EDIT:
I've just tried the same debug in a Console app and it works as expected. The other project is a Silverlight 4 application, why are they different?
Silverlight 4 Debug Screen Shot:
EDIT: Reply from Microsoft Connect:
"This was an omission on our part - we had previously fixed this exact issue for Visual Studio 2008 SP1, but this fix was unfortunately not ported to the Visual Studio 2010 codebase. This is now fixed again (this time for good!) and we're looking into shipping this fix in VS2010 SP1.
Alex Turner
Program Manager
Visual Basic and C# Compiler" So it should be fixed soon.
EDIT: I've just double checked this in SP1 and it is working correctly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有一种解决方法可以将字典的内容转储到调试器中。
在您的项目中,添加对 linq dll 的引用(例如 System.Core)
将以下语句添加到您的 项目中源文件:
using System.Linq;
在监视窗口中,键入:
test.Take(1)
然后展开“结果视图”组行。这将为您提供熟悉的键值对列表。
[rickpastoor 在 connect.microsoft.com 上报告了 Bug 557741 的解决方法]
There is a workaround to dump the contents of the dictionary in the debugger.
To your project, add a reference to the linq dll (e.g. System.Core)
Add the following statement to your source file:
using System.Linq;
In the watch window, type:
test.Take(1)
Then expand the "Results View" group row. This should give you the familiar list of key, value pairs.
[This workaround was reported by rickpastoor on connect.microsoft.com for Bug 557741]
Dictionary 的调试器可视化工具是完全相同的类,具有完全相同的行为。它仍然是私有的 Mscorlib_DictionaryDebugView 类。未展开时它显示计数,展开时它显示元素数组。
您的代码片段表明您正在使用完全不同的 Dictionary 类,该类不是通用的。
The debugger visualizer for Dictionary is the exact same class with the exact same behavior. It is still the private Mscorlib_DictionaryDebugView class. Unexpanded it shows Count, expanded it shows an array of the elements.
Your code snippet suggests that you are using a completely different Dictionary class, one that is not generic.