为什么字典调试可视化工具在 Visual Studio 2010 中对于 Silverlight 调试不太有用?

发布于 2024-08-31 21:20:11 字数 1093 浏览 2 评论 0原文

我正在 Visual Studio 2010(我们刚刚安装)中进行调试,并尝试在快速监视窗口中查看字典。我看到了键和值,但深入研究这些显示了计数和非公共成员,非公共成员继续跟踪,我从未在字典中看到这些值。我可以运行 test.Take(10) 并查看值,但为什么我必须这样做。我没有安装 VS 2008 来进行比较,但似乎我可以更轻松地调试字典。为什么现在变成这样了?这只是我在机器上以某种方式设置的设置吗?

测试代码:

  Dictionary<string, string> test = new Dictionary<string, string>();
    test.Add("a", "b");

编辑: 我刚刚在控制台应用程序中尝试了相同的调试,它按预期工作。另一个项目是Silverlight 4应用程序,为什么它们不同?

控制台调试屏幕截图

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?

Console Debug Screen Shot

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

烟雨扶苏 2024-09-07 21:20:11

有一种解决方法可以将字典的内容转储到调试器中。

  1. 在您的项目中,添加对 linq dll 的引用(例如 System.Core)

  2. 将以下语句添加到您的 项目中源文件:

    using System.Linq;

  3. 在监视窗口中,键入:

    test.Take(1)

  4. 然后展开“结果视图”组行。这将为您提供熟悉的键值对列表。

[rickpastoor 在 connect.microsoft.com 上报告了 Bug 557741 的解决方法]

There is a workaround to dump the contents of the dictionary in the debugger.

  1. To your project, add a reference to the linq dll (e.g. System.Core)

  2. Add the following statement to your source file:

    using System.Linq;

  3. In the watch window, type:

    test.Take(1)

  4. 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]

埖埖迣鎅 2024-09-07 21:20:11

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文