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 Size(800, 600);
windowService.ShowDialog(host);
}
}
}
catch (Exception ex)
{
MessageBox.Show(string.Format("Error!\n{0}", ex), "Object Visualizer");
}
} } }
Any ideas?