none
How to write custom visualizer? RRS feed

  • Question

  • Background: I want to create a visualizer for a C++ structure (call it S) I have defined (it consists of several integers). The visualizer should create a graphic (picture); I have written the C++ code that renders the image on the screen in MFC.

    As I understand it, a custom visualizer is able to recognize the type S and obtain the serialized values of the members of S. The visualizer would then render the image in some type cf control or data tip.

    I cannot get the directions on the Microsoft docs page  Walkthrough: Writing a Visualizer in C# to work:

    For "MyFirstVisualizer" (without the template), I can't add references--there is no References to right-click in Solution Explorer (this is step 3, to Add Reference).

    For "MySecondVisualizer", the class library is created, but when I attempt to add a visualizer item, I get a warning "The reference "System" could not be added to the project. This wizard will continue to run, but the resulting project may not build properly." And when I do try to build it, I get these errors:

    1>SecondVisualizer.cs(1,17,1,29): error CS0234: The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
    1>SecondVisualizer.cs(4,22,4,27): error CS0234: The type or namespace name 'Forms' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?)
    1>SecondVisualizer.cs(20,37,20,61): error CS0246: The type or namespace name 'DialogDebuggerVisualizer' could not be found (are you missing a using directive or an assembly reference?)
    1>SecondVisualizer.cs(22,38,22,62): error CS0246: The type or namespace name 'IDialogVisualizerService' could not be found (are you missing a using directive or an assembly reference?)
    1>SecondVisualizer.cs(22,78,22,103): error CS0246: The type or namespace name 'IVisualizerObjectProvider' could not be found (are you missing a using directive or an assembly reference?)
    1>SecondVisualizer.cs(22,33,22,37): error CS0115: 'SecondVisualizer.Show(IDialogVisualizerService, IVisualizerObjectProvider)': no suitable method found to override

    How can I create a visualizer correctly, and without errors?



    Sunday, February 3, 2019 6:47 AM

All replies

  • Hi,

    My understanding is that you just view the sample about how to write a Visualizer in C#, but the real issue is that you want to use the VC++. You can view samples about how to use the .natvis file.

    https://blogs.msdn.microsoft.com/vcblog/2015/09/28/debug-visualizers-in-visual-c-2015/

    https://docs.microsoft.com/en-us/visualstudio/debugger/create-custom-views-of-native-objects?view=vs-2017

    Best Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, February 5, 2019 2:09 AM
    Moderator
  • No, you have misunderstood. The app I want to use the visualizer with is C++; the language I will write the visualizer in is C#. Since I want a custom visualizer showing a picture (graphic) in a separate window, the .natvis approach is not applicable.

    The Microsoft doc I referenced is a walkthrough on writing such a visualizer, using Windows Forms. But the directions are incorrect, incomplete, or out-of-date, because they don't work.

    My questions are, where can I find directions on how to write a custom visualizer, or examples of same. And, why does Windows Forms and setting references as described in the walkthrough not work? Perhaps the VS2017 installation is incomplete or corrupted?

    Tuesday, February 5, 2019 6:08 AM