开发者

Debugger Visualizer, ElementHost, and Edit and Continue problems

I recently wrote a custom Debugger Visualizer for Visual Studio 2008 for one of the custom types in my application. The UI for the visualizer is written in WPF and is hosted in an element host and shown using the IDialogVisualizerService windowService object.

Everything works great, and my visualizer loads and shows the relevant information, but if try to "edit and continue" in my application after loading the visualizer, Visual Studio crashes with no useful error message.

In trying to debug this I removed almost all of my code from the solution to the point where I was only serializing a string with the ObjectSource and displaying just an empty element host and I still get the crash on edit and continue. If I remove the element host and show a WinForms control or form there is no crash.

Here is the Visualizer code:

using System;
using System.Drawing;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using System.Windows.Forms;
using System.Windows.Forms.Integration;
using Microsoft.VisualStudio.DebuggerVisualizers;
using ObjectVisualizerShared;
using ObjectVisualizerUI;

namespace ObjectVisualizer
{
    public class Visualizer : DialogDebuggerVisualizer
    {
        protected override void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider)
        {
            try
            {

                Stream stream = objectProvider.GetData();
                if (stream.Length > 0)
                {
                    BinaryFormatter formatter = new BinaryFormatter();
                    VisualizerNode node = (VisualizerNode)formatter.Deserialize(stream);
                    if (node != null)
                    {
                        VisualizerWindow window = new VisualizerWindow(node);
                        ElementHost host = new ElementHost();
                        host.Child = window;
                        host.Dock = DockStyle.Fill;
                        host.Size = new Siz开发者_如何学编程e(800, 600);
                        windowService.ShowDialog(host);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Error!\n{0}", ex), "Object Visualizer");
            }
        }
    }
}

Any ideas?


While I didn't really find a "proper" fix, I have found an acceptable workaround.

I moved my visualization into an entirely separate program, and then in my debugger visualizer I start the visualization program in a separate process and I send the data object to it using a named pipe.

This is working well, and has the added advantage that the visualization windows persist across data changes and debug sessions.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜