Debugger Visualizer not working? Have i incorrectly registered it?

我与影子孤独终老i 提交于 2019-12-20 03:18:10

问题


I have created a debugger visualizer in VS2008. There are two classes i've made, in the same .dll :-

  • BinaryDataDebuggerVisualizer
  • ImageDebuggerVisualizer

The image one works fine (eg. the magnify glass appears in debug mode) but not for the byte[] one (BinaryDataDV). What my visualizer does is display the binary data as an image in a modal window (if the data is a legit image). I compiled to code in Release mode, then dropped the .dll into C:\Users\\Documents\Visual Studio 2008\Visualizers

this is the code that i used to 'define' the vis...

using

System;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using Microsoft.VisualStudio.DebuggerVisualizers;
using Foo.DebuggerVisualizers;  

[assembly: DebuggerVisualizer(
    typeof (BinaryDataDebuggerVisualizer),
    typeof (VisualizerObjectSource),
    Target = typeof (byte[]),
    Description = "Binary Data to Image Visualizer")]

namespace Foo.DebuggerVisualizers
{
    public class BinaryDataDebuggerVisualizer : DialogDebuggerVisualizer
    {
        protected override void Show(IDialogVisualizerService windowService,
           IVisualizerObjectProvider objectProvider)
        {
            ... my code in here
        }
     }
}

I've made a unit test in the debugger visualizer solution, which fires up and test the code .. which it correctly shows a legit (and also illegal) image files. so i believe the code is ok.

When i'm in my real solution, this is what i'm doing (where i expect the magnify glass to show, when i'm hovering over the variable in debug mode).

byte[] data = File.ReadAllBytes("Chick.jpg");

then i hover over the variable data when i've paused the code while debugging, on that line (using a breakpoint).

No hourglass :(

anyone have any ideas to what is wrong?


回答1:


Unfortunately this is not possible. There is a limitation in the Debugger Visualizer framework that prevents them from functioning on array types or object.

http://msdn.microsoft.com/en-us/library/e2zc529c.aspx

Quote from the page: "You can write a custom visualizer for an object of any managed class except for Object or Array"



来源:https://stackoverflow.com/questions/346154/debugger-visualizer-not-working-have-i-incorrectly-registered-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!