• DebuggerVisualizer时,序列化引出的问题。


    实现如下功能:http://www.cnblogs.com/devil0153/archive/2010/09/01/Visual-Studio-Custom-Debugger.html#2889243

    参考的例子没问题。我把参考的例子 MyTable 对象, 继承自  Dictionary<string,string>  发现报错:

    未找到反序列化“CustomDebugger.MyTable”类型对象的构造函数。

    MyTable 对象应该如下定义:

    [DebuggerVisualizer(typeof(MyTableDebuggerVisualizer))]
        [Serializable]
        public class MyTable : Dictionary<string, string>
        {
            public MyTable()
            {
                this.Columns = new MyColumnCollection();
                this.Rows = new MyRowCollection();
            }
            public override void GetObjectData(SerializationInfo info, StreamingContext context)
            {
                info.AddValue("Rows", this.Rows);
                info.AddValue("Columns", this.Columns);
                base.GetObjectData(info, context);
            }
    
            MyTable(SerializationInfo info, StreamingContext context)
                : base(info, context)
            {
                this.Rows = info.GetValue("Rows", typeof(MyRowCollection)) as MyRowCollection;
                this.Columns = info.GetValue("Columns", typeof(MyColumnCollection)) as MyColumnCollection;
            }
    
            public MyColumnCollection Columns { get; private set; }
            public MyRowCollection Rows { get; private set; }
        }
    

    问题解决。再一次加深了对 反序列化的印象。

  • 相关阅读:
    11.菜单(一)
    线性表之顺序存储详解
    SVN 撤回已提交的代码
    线性表1
    顶层父类
    异常类之派生类
    new和delete重载
    异常类之基类
    Qt中多线程问题
    智能指针实例
  • 原文地址:https://www.cnblogs.com/newsea/p/3610376.html
Copyright © 2020-2023  润新知