话说:使用CYQ.Data时,会经常断点MDataTable的对象,为了查看表格的数据内容,在监视里会常ToDataTable(),然后借可DataTable的可视化方式查看表格。
using Microsoft.VisualStudio.DebuggerVisualizers;
using System;
using System.Drawing;
using System.Windows.Forms;
[assembly: System.Diagnostics.DebuggerVisualizer(
typeof(CYQ.Visualizer.ImageVisualizer),
typeof(VisualizerObjectSource),
Target = typeof(System.Drawing.Image),
Description = "Image Visualizer")]
namespace CYQ.Visualizer
{
public class ImageVisualizer : DialogDebuggerVisualizer
{
override protected void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider)
{
Image image = (Image)objectProvider.GetObject();
Form form = new Form();
form.Text = string.Format("Width: {0}, Height: {1}", image.Width, image.Height);
form.ClientSize = new Size(image.Width, image.Height);
form.FormBorderStyle = FormBorderStyle.FixedToolWindow;
PictureBox pictureBox = new PictureBox();
pictureBox.Image = image;
pictureBox.Parent = form;
pictureBox.Dock = DockStyle.Fill;
windowService.ShowDialog(form);
}
}
}
一句话,把那个Xxx.dll放到以下目录:VS安装目录\Microsoft Visual Studio XXX\Common7\Packages\Debugger\Visualizers
对于不同的VS(2005、2008、2012、2015),你需要编绎不同的版本,主要是引用的:Microsoft.VisualStudio.DebuggerVisualizers 这个版本不一样。