Click here to Skip to main content
11,505,744 members (60,706 online)
Click here to Skip to main content

A Generic List and Dictionary Debugger Visualizer for VS.NET

, 27 Aug 2011 CPOL 85.6K 3.1K 96
Rate this:
Please Sign up or sign in to vote.
A cool List and Dictionary debugger visualizer for VS.NET 2005, 2008 and 2010
ListVisualizer2008

Introduction

This is a simple List<T> and Dictionary<T,T> debugger visualizer for Visual Studio .NET 2005, 2008 and 2010. The only requirement for it to work is that the classes inside the lists or dictionaries should be marked as [Serializable].

Background

I used the nice article Create a Debugger Visualizer in 10 Lines of Code as a starting point. I recommend this article for further details on how to implement a custom debugger visualizer.

Using the Code

For installing the visualizer only, download the List Visualizer 2005, 2008 or 2010 according to the Visual Studio .NET version you would like to use. Run install_vs2005.cmd, install_vs2008.cmd or install_vs2010.cmd in a Visual Studio Command Prompt window. For Windows Vista, make sure to run the command prompt as Administrator.

Note that the Visual Studio path in the cmd files uses the default installation path, c:\Program Files\Microsoft Visual Studio 8 (for VS.NET 2005), c:\Program Files\Microsoft Visual Studio 9.0 (for VS.NET 2008) and c:\Program Files\Microsoft Visual Studio 10.0 (for VS.NET 2010). If you installed it in a different location, you might need to change the bat file and the post build events in the projects.

The default path for visualizers in 2005 is C:\Program Files\Microsoft Visual Studio 8\Common7\Packages\Debugger\Visualizers, in 2008 is c:\Program Files\Microsoft Visual Studio 9.0\Common7\Packages\Debugger\Visualizers and in 2010 is c:\Program Files\Microsoft Visual Studio 10.0\Common7\Packages\Debugger\Visualizers. Just copy the assemblies there for a manual installation.

The source code contains both VS.NET 2005 (ListVisualizer.sln) and VS.NET 2008 solutions (ListVisualizer2008.sln). The post build event automatically deploys the visualizer for testing. Note that ListVisualizer2008.sln also contains the VS.NET 2005 projects that may be removed in case 2005 is not installed.

The source code for VS.NET 2010 can be found in a different zip file.

Points of Interest

I had to cast the generic types to non-generic interfaces to work with the variable that is being debugged:

// Get the list
IList list = (IList)objectProvider.GetObject();
 
// Get the dictionary
IDictionary dict = (IDictionary)objectProvider.GetObject();

After that, I used Reflection to retrieve object properties and fields to be displayed in the grid view:

// Retrieve the properties
PropertyInfo[] properties = singleObj.GetType().GetProperties();
foreach (PropertyInfo property in properties)
{
    dgvList.Columns.Add(property.Name, property.Name);
    columns.Add(property.Name, "P");
}
// Retrieve the fields
FieldInfo[] fields = singleObj.GetType().GetFields();
foreach (FieldInfo field in fields)
{
    dgvList.Columns.Add(field.Name, field.Name);
    columns.Add(field.Name, "F");
}

The solution contains six projects - the Dictionary Visualizer for 2005 and 2008, the List Visualizer for 2005 and 2008, the testing project ListVisualizerTest, and the class library that does most of the work, VisualizerLib. ListVisualizerTest is used to debug different types of Lists and Dictionaries and is also used to create the UI for the visualizers.

History

  • 15th April, 2008: Initial post
  • 3rd July, 2010: Article updated - created the new visualizer for Visual Studio 2010
  • 26th August, 2011: Article updated - visualizer for all Visual Studio versions can now be resized

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Daniel Carvalho Liedke
Software Developer (Senior)
Brazil Brazil
I started development 22 years from now, since MSX basic. Started Windows programming with VB 2.0 and Web programming with ASP 3.0. Now I build Windows Forms, Web Applications, NT services and WPF applications using Microsoft.NET. I am MCP in Visual Basic 6.0, MCAD and MCSD.NET in Framework 1.1 ,MCPD Web in Framework 2.0, MCTS in .NET 3.5 workflow, MCTS in .NET 3.5 communication foundation and windows presentation foundation. Besides programming I love surfing.

Comments and Discussions

 
NewsHow to fix "Operation is not supported issue" when running the debugger Pin
Daniel Carvalho Liedke14-Jan-13 8:12
memberDaniel Carvalho Liedke14-Jan-13 8:12 
Questionwhy need Serializable Pin
grace&grace27-Jun-12 16:06
membergrace&grace27-Jun-12 16:06 
AnswerRe: why need Serializable Pin
Daniel Carvalho Liedke28-Jun-12 14:52
memberDaniel Carvalho Liedke28-Jun-12 14:52 
Questioncan't make it work v2010 x64 Pin
mikedepetris19-Jan-12 10:21
membermikedepetris19-Jan-12 10:21 
AnswerRe: can't make it work v2010 x64 Pin
Daniel Carvalho Liedke20-Jan-12 7:25
memberDaniel Carvalho Liedke20-Jan-12 7:25 
QuestionForm is blank - no grid shown Pin
jeff.harris165-Jan-12 3:47
memberjeff.harris165-Jan-12 3:47 
AnswerRe: Form is blank - no grid shown Pin
Daniel Carvalho Liedke6-Jan-12 12:13
memberDaniel Carvalho Liedke6-Jan-12 12:13 
GeneralRe: Form is blank - no grid shown Pin
David Laub12320-Feb-13 10:38
memberDavid Laub12320-Feb-13 10:38 
GeneralRe: Form is blank - no grid shown Pin
David Laub12320-Feb-13 11:14
memberDavid Laub12320-Feb-13 11:14 
SuggestionRemove Source Code Control and User Files Pin
Andy Missico8-Sep-11 4:22
memberAndy Missico8-Sep-11 4:22 
GeneralRe: Remove Source Code Control and User Files Pin
Daniel Carvalho Liedke28-Dec-11 4:27
memberDaniel Carvalho Liedke28-Dec-11 4:27 
QuestionImprovement + other visualizer Pin
I'm Chris29-Aug-11 23:00
memberI'm Chris29-Aug-11 23:00 
AnswerRe: Improvement + other visualizer Pin
Daniel Carvalho Liedke28-Dec-11 4:24
memberDaniel Carvalho Liedke28-Dec-11 4:24 
GeneralRe: Improvement + other visualizer Pin
I'm Chris9-Jan-12 6:34
memberI'm Chris9-Jan-12 6:34 
QuestionGreat! But why fix the output screen? Pin
Owin_wan_kenobi26-Aug-11 3:45
memberOwin_wan_kenobi26-Aug-11 3:45 
AnswerRe: Great! But why fix the output screen? Pin
Daniel Carvalho Liedke26-Aug-11 5:05
memberDaniel Carvalho Liedke26-Aug-11 5:05 
GeneralRe: Great! But why fix the output screen? Pin
Daniel Carvalho Liedke26-Aug-11 7:39
memberDaniel Carvalho Liedke26-Aug-11 7:39 
GeneralRe: Great! But why fix the output screen? Pin
Daniel Carvalho Liedke28-Aug-11 4:14
memberDaniel Carvalho Liedke28-Aug-11 4:14 
NewsDebugger Visualizer doesn't support C++\CLI. Pin
kas25-May-11 6:44
memberkas25-May-11 6:44 
GeneralRe: Debugger Visualizer doesn't support C++\CLI. Pin
Daniel Carvalho Liedke25-May-11 13:07
memberDaniel Carvalho Liedke25-May-11 13:07 
Thanks for the note! Big Grin | :-D
QuestionSilverlight Support? Pin
Stepjan Hejne25-Jan-11 3:54
memberStepjan Hejne25-Jan-11 3:54 
AnswerRe: Silverlight Support? Pin
Daniel Carvalho Liedke25-Jan-11 7:53
memberDaniel Carvalho Liedke25-Jan-11 7:53 
GeneralError message Pin
awstam6-Jan-11 0:15
memberawstam6-Jan-11 0:15 
GeneralRe: Error message Pin
Daniel Carvalho Liedke6-Jan-11 1:38
memberDaniel Carvalho Liedke6-Jan-11 1:38 
Generalx64 Runtime Support Pin
CitizenDC30-Dec-10 22:43
memberCitizenDC30-Dec-10 22:43 
GeneralRe: x64 Runtime Support Pin
Daniel Carvalho Liedke6-Jan-11 1:40
memberDaniel Carvalho Liedke6-Jan-11 1:40 
GeneralVisualizer not showing up Pin
ooglee10-Nov-10 2:39
memberooglee10-Nov-10 2:39 
GeneralRe: Visualizer not showing up Pin
Daniel Carvalho Liedke10-Nov-10 3:46
memberDaniel Carvalho Liedke10-Nov-10 3:46 
GeneralRe: Visualizer not showing up Pin
ooglee10-Nov-10 18:38
memberooglee10-Nov-10 18:38 
GeneralRe: Visualizer not showing up Pin
Daniel Carvalho Liedke6-Jan-11 1:41
memberDaniel Carvalho Liedke6-Jan-11 1:41 
GeneralFunny, I had the same issue Pin
Norman-Timo10-Jul-10 15:14
memberNorman-Timo10-Jul-10 15:14 
GeneralMy vote of 4 Pin
Norman-Timo10-Jul-10 15:06
memberNorman-Timo10-Jul-10 15:06 
GeneralRe: My vote of 4 Pin
Daniel Carvalho Liedke6-Jan-11 1:41
memberDaniel Carvalho Liedke6-Jan-11 1:41 
GeneralVisual Studio 2010 Pin
Darvon4u2-Jul-10 3:19
memberDarvon4u2-Jul-10 3:19 
GeneralRe: Visual Studio 2010 Pin
Daniel Carvalho Liedke3-Jul-10 4:41
memberDaniel Carvalho Liedke3-Jul-10 4:41 
GeneralRe: Visual Studio 2010 Pin
Daniel Carvalho Liedke3-Jul-10 7:28
memberDaniel Carvalho Liedke3-Jul-10 7:28 
GeneralReflection Exception "Parameter count mismatch" Pin
Ivan Mitev15-Mar-10 23:06
memberIvan Mitev15-Mar-10 23:06 
GeneralRe: Reflection Exception "Parameter count mismatch" Pin
Daniel Carvalho Liedke16-Mar-10 13:23
memberDaniel Carvalho Liedke16-Mar-10 13:23 
GeneralNot working for me Pin
Member 25929352-Jan-09 10:50
memberMember 25929352-Jan-09 10:50 
GeneralRe: Not working for me Pin
Daniel Carvalho Liedke2-Jan-09 15:47
memberDaniel Carvalho Liedke2-Jan-09 15:47 
GeneralRe: Not working for me Pin
slowram17-Sep-10 13:50
memberslowram17-Sep-10 13:50 
GeneralRe: Not working for me Pin
Daniel Carvalho Liedke18-Sep-10 1:50
memberDaniel Carvalho Liedke18-Sep-10 1:50 
QuestionWhat about custom lists? Pin
Qwertie18-Jul-08 12:09
memberQwertie18-Jul-08 12:09 
AnswerRe: What about custom lists? Pin
Daniel Carvalho Liedke19-Jul-08 4:42
memberDaniel Carvalho Liedke19-Jul-08 4:42 
GeneralRe: What about custom lists? Pin
Qwertie19-Jul-08 5:33
memberQwertie19-Jul-08 5:33 
GeneralRe: What about custom lists? Pin
Daniel Carvalho Liedke19-Jul-08 16:32
memberDaniel Carvalho Liedke19-Jul-08 16:32 
GeneralGreat! Pin
merlin98116-Apr-08 3:57
membermerlin98116-Apr-08 3:57 
GeneralRe: Great! Pin
Daniel Carvalho Liedke16-Apr-08 6:02
memberDaniel Carvalho Liedke16-Apr-08 6:02 
GeneralNice to include an install script, but... Pin
OregonGhost15-Apr-08 22:53
memberOregonGhost15-Apr-08 22:53 
GeneralRe: Nice to include an install script, but... Pin
Daniel Carvalho Liedke16-Apr-08 2:02
memberDaniel Carvalho Liedke16-Apr-08 2:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150520.1 | Last Updated 27 Aug 2011
Article Copyright 2008 by Daniel Carvalho Liedke
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid