Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio is not loading my debugger visualizer

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?

like image 609
Tom Ritter Avatar asked Aug 13 '10 15:08

Tom Ritter


People also ask

Does Visual Studio have a debugger?

The Visual Studio debugger can help you navigate through code to inspect the state of an app and show its execution flow, which is also known as code stepping. You can use keyboard shortcuts, debug commands, breakpoints, and other features to quickly get to the code you want to examine.


2 Answers

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.

like image 56
Michel de Ruiter Avatar answered Nov 03 '22 01:11

Michel de Ruiter


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()
{
like image 34
Bryce Wagner Avatar answered Nov 03 '22 00:11

Bryce Wagner