6

I wrote my own Debugger Visualizer.

It, and the attributes, are in their own assembly. There is no references or attributes in the assembly containing the class to be debugged - I want to make a drop-in dll that is optional for people to use.

The class I am trying to debug is a generic.

[Serializable]
public class FinCellTable<S> : IFinCellTable, IEnumerable<List<FinCell.IFinCell>>
    where S : class, FinCell.IFinHeaderCell, FinCell.IFinCell, new()

Here is the visualizer:

[assembly: System.Diagnostics.DebuggerVisualizer(
        typeof(Financials.Debugging.CellTableVisualizer),
        typeof(VisualizerObjectSource),
        Target = typeof(Financials.Transformation.IFinCellTable),
        Description = "FinCell Table Visualizer")]
[assembly: System.Diagnostics.DebuggerVisualizer(
        typeof(Financials.Debugging.CellTableVisualizer),
        typeof(VisualizerObjectSource),
        Target = typeof(Financials.Transformation.FinCellTable<Financials.FinCell.FinHeaderCell>),
        Description = "FinCell Table Visualizer")]

namespace Financials.Debugging
{
    public class CellTableVisualizer : DialogDebuggerVisualizer
    {
        protected override void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider)
        {
            if (windowService == null) throw new ArgumentNullException("windowService");
            if (objectProvider == null) throw new ArgumentNullException("objectProvider");

            var data = (IFinCellTable)objectProvider.GetObject();
            using (var displayForm = new CellTableVizForm())
            {
                displayForm.PopulateForm(data);
                windowService.ShowDialog(displayForm);
            }
        }
    }
}

I am running Visual Studio 2010, and the following directory contains the .dll and .pdb of the Visualizer Assembly:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Packages\Debugger\Visualizers

I place a breakpoint on an instance of IFinCellTable that is specifically FinCellTable. It does not show the magnifying glass.

I debugged Visual Studio using another Visual Studio as the first VS was debugging. I watched the output window as the first VS loaded dll's. When I triggered a visualizer on a datatable, the second VS outputted that it loaded Microsoft.VisualStudio.DebuggerVisualizers.dll and Microsoft.VisualStudio.Debugger.DataSetVisualizer.dll (the latter from the correct directory I said above). (The Modules window behaves/shows the same.)

So obviously my Debugger Visualizer Drop-In assembly is not be loaded by VS, so it doesn't know to show the magnifying glass.

How do you get visual studio to load Visualizers up-front, so drop-in visualizers work and you don't need to edit your original code?

3
  • Nothing jumps out. You did restart VS after copying the visualizer, right? Commented Aug 13, 2010 at 16:58
  • Do you need to do some sort of UI or environment reload? This was required for add-ons in prior versions. Commented Nov 5, 2010 at 14:25
  • Strange. I did exactly what you describe here: adamjamesnaylor.com/… and it seemed to work ok. As Michel asks, are you sure it's in the correct folder? I ask because at work my Visual Studio User folder is on a network share and VS throws security exceptions when trying to access off the share. Commented Aug 21, 2012 at 20:19

4 Answers 4

3

Wild guess: are you sure the correct files are in C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Packages\Debugger\Visualizers, not in C:\Users\<you>\AppData\Local\VirtualStore\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Packages\Debugger\Visualizers?

If yes, that's due to UAC Virtualization.

Sign up to request clarification or add additional context in comments.

Comments

2

This question is over 5 years old, so I assume it's no longer relevant to the original poster, but for anyone else trying to do something similar:

System.Diagnostics.DebuggerVisualizer does not work when target is an interface. You have to specify a concrete type. You have to specify the attribute on every single concrete type you want to visualize:

[System.Diagnostics.DebuggerVisualizer("Financials.Debugging.CellTableVisualizer, Financials.Debugging, Version=1.0.0.0, Culture=neutral, PublicKeyToken=...")]
[Serializable]
public class FinCellTable<S> : IFinCellTable, IEnumerable<List<FinCell.IFinCell>>
    where S : class, FinCell.IFinHeaderCell, FinCell.IFinCell, new()
{

Comments

0

I believe this can be disabled in Tools > Options: If you do not see the effects of DebuggerDisplay or DebuggerTypeProxy ensure that Tools > Options > Debugging > General > Show raw structure of objects in variables windows is NOT checked.

Comments

0

The correct folder to place it is: C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Packages\Debugger\Visualizers. Once you place this DLL there and restart visual studio then you should get a "magnifying glass" over "Expression" type of variables (in debugging mode you will get it in watch window and also when you move your mouse cursor over the variable)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.