DataSet的序列化和反序列化
----------------------------kuailewangzi1212
--http://topic.csdn.net/u/20070713/11/6acc7b7f-b099-4f04-a77e-97a3b3d782cf.html
问题解决了,谢谢大家的帮助!
我把解决方法贴出来希望对大家有帮助
------------------------------------
[System.ComponentModel.DesignerCategory( "Code ")]
[SerializableAttribute]
public class BaseDataSet:System.Data.DataSet,ISerializable
{
private System.Collections.ArrayList columnPropertyList;
public System.Collections.ArrayList ColumnPropertyList
{
get
{
return this.columnPropertyList;
}
set
{
this.columnPropertyList=value;
}
}
public void AddColumnPropertyList(ColumnProperty col)
{
columnPropertyList.Add(col);
}
/// <summary>
/// 返回列的属性对象
/// </summary>
/// <param name= "str_col "> 列名 </param>
/// <returns> </returns>
public ColumnProperty GetColProperty(string str_col)
{
foreach(ColumnProperty op in columnPropertyList)
{
if(op.Column==str_col)
{
return op;
}
}
return null;
}
public BaseDataSet(SerializationInfo info, StreamingContext context) : base(info, context)
{
columnPropertyList=(System.Collections.ArrayList)info.GetValue( "List ",typeof(System.Collections.ArrayList));
}
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
{
Type t = typeof(DataSet);
MethodInfo mi = t.GetMethod( "System.Runtime.Serialization.ISerializable.GetObjectData ",
BindingFlags.Instance | BindingFlags.NonPublic);
mi.Invoke(this, new object[]{info,context});
info.AddValue( "List ", columnPropertyList);
}
}