简体   繁体   中英

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?

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 .

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()
{

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)

我相信可以在工具>选项中禁用它:如果没有看到DebuggerDisplay或DebuggerTypeProxy的效果,请确保未选中工具>选项>调试>常规>显示变量窗口中对象的原始结构。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM