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; }
}
问题解决。再一次加深了对 反序列化的印象。
|
作者:NewSea 出处:http://newsea.cnblogs.com/
QQ,MSN:iamnewsea@hotmail.com 如无特别标记说明,均为NewSea原创,版权私有,翻载必纠。欢迎交流,转载,但要在页面明显位置给出原文连接。谢谢。 |

浙公网安备 33010602011771号