Why is the dictionary debug visualizer less useful in Visual Studio 2010 for Silverlight debugging?
Asked Answered
A

2

10

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.

Artemus answered 7/5, 2010 at 15:11 Comment(2)
I've accepted Hans Passant's answer and submitted a bug report to Microsoft. We'll see what happens : connect.microsoft.com/VisualStudio/feedback/details/557741/….Artemus
Yup, I'm having the same problem and it blows. Microsoft confirms its a bug in VS 2010 (not a beta) and there may by a fix in SP1.Shivaree
P
0

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.

Punctual answered 7/5, 2010 at 17:37 Comment(4)
I just edited my question... I had the formatting incorrect, which hid the <string, string> generic of the definition.Artemus
Right, that would do it. Does your snippet actually repro the problem?Punctual
Please see my updated edit, it seems to be different for a Silverlight app vs. a Console app.Artemus
@Kevin, the links are fumbled. But I repro for Silverlight4, I missed that part of your question. It still has the same visualizer, but it doesn't work in the debugger. The Silverlight tools are still in beta, you can tell about the bug by posting to connect.microsoft.comPunctual
T
4

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]

Topsail answered 5/11, 2010 at 17:30 Comment(0)
P
0

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.

Punctual answered 7/5, 2010 at 17:37 Comment(4)
I just edited my question... I had the formatting incorrect, which hid the <string, string> generic of the definition.Artemus
Right, that would do it. Does your snippet actually repro the problem?Punctual
Please see my updated edit, it seems to be different for a Silverlight app vs. a Console app.Artemus
@Kevin, the links are fumbled. But I repro for Silverlight4, I missed that part of your question. It still has the same visualizer, but it doesn't work in the debugger. The Silverlight tools are still in beta, you can tell about the bug by posting to connect.microsoft.comPunctual

© 2022 - 2024 — McMap. All rights reserved.