Visual Studio 2019 自定义可视化调试工具的坑

Visual Studio  自定义可视化调试工具已有大量文章介绍,这里不再啰嗦。如果不懂建议看看https://www.cnblogs.com/cyq1162/p/4551652.html 

https://docs.microsoft.com/en-us/visualstudio/debugger/walkthrough-writing-a-visualizer-in-csharp?view=vs-2019

本人也胡乱弄了个可视化调试 显示一组中间计算曲线,开始一切顺利,技术难度也不大。

代码及运行效果如下:

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using FirstLineTamping.Infrastructure.Measure;
using LineView;
using Microsoft.VisualStudio.DebuggerVisualizers;
[assembly: System.Diagnostics.DebuggerVisualizer(typeof(TMGC_DV.TMGC_Visualizer), typeof(VisualizerObjectSource), Target = typeof(FirstLineTamping.Infrastructure.Measure.MeasSet), Description = "TMGC MeasSet Visualizer")]
[assembly: System.Diagnostics.DebuggerVisualizer(typeof(TMGC_DV.TMGC_Visualizer), typeof(VisualizerObjectSource), Target = typeof(FirstLineTamping.Infrastructure.Measure.VerschArray), Description = "TMGC VerschArray Visualizer")]
[assembly: System.Diagnostics.DebuggerVisualizer(typeof(TMGC_DV.TMGC_Visualizer), typeof(VisualizerObjectSource), Target = typeof(FirstLineTamping.Contract.Entities.Offsets.TrackOffset), Description = "TMGC TrackOffset Visualizer")]
[assembly: System.Diagnostics.DebuggerVisualizer(typeof(TMGC_DV.TMGC_Visualizer), typeof(VisualizerObjectSource), Target = typeof(List<MeasRecord>), Description = "TMGC List<MeasRecord> Visualizer")]
[assembly: System.Diagnostics.DebuggerVisualizer(typeof(TMGC_DV.TMGC_Visualizer), typeof(VisualizerObjectSource), Target = typeof(FittingMeasure.PosValueArray), Description = "TMGC PosValueArray Visualizer")]
namespace TMGC_DV
{ 
    public class TMGC_Visualizer : DialogDebuggerVisualizer
    {
        protected override void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider)
        {
            var s = objectProvider.GetObject();

            Db_Form f = new Db_Form();
            Debug.WriteLine("DialogDebuggerVisualizer :" + objectProvider.ToString ());
            if (s is FirstLineTamping.Infrastructure.Measure.MeasSet)
            {
                f.AddMeasGrph(s as FirstLineTamping.Infrastructure.Measure.MeasSet);
                f.Text = "Measure.MeasSet";
            }
            if (s is FirstLineTamping.Infrastructure.Measure.VerschArray)
            {
                f.AddMeasGrph(s as FirstLineTamping.Infrastructure.Measure.VerschArray);
            }
            if (s is FirstLineTamping.Contract.Entities.Offsets.TrackOffset)
            {
                f.AddMeasGrph(s as FirstLineTamping.Contract.Entities.Offsets.TrackOffset);
            }
            if (s is List<MeasRecord> )
            {
                f.AddMeasGrph(s as List<MeasRecord>);
            }
            if (s is FittingMeasure.PosValueArray)
            {
                f.AddMeasGrph(s as FittingMeasure.PosValueArray);
                f.Text = "PosValueArray";
            }
            f.ShowDialog();

        }
        public static void TestShowVisualizer(object objectToVisualize)
        {
            VisualizerDevelopmentHost visualizerHost = new VisualizerDevelopmentHost(objectToVisualize, typeof(TMGC_Visualizer));
            visualizerHost.ShowVisualizer();
        }
    }
}

运行效果 

昨天更新了到了 Microsoft Visual Studio Professional 2019 版本 16.4.5

我的工具就不会工作了,总是显示:

在网上搜索半天发现:Visual Studio Professional 2019 要求被调试对象是 “可信任"程序,否则不能使用自定义调试工具!

折腾半天!

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值