DataSet序列化后反序列化乱码的问题
数据库:Oracle8i+.net2.0(VS2005) ,序列化时使用微软的DataSetSurrogate,在序列化的时候,直接通过查询语句(比如Select * from Table)生成DataSet(里面有多个表),然后通过如下方式进行序列化:
private static bool BinarySerialize(ICryptoTransform encryptor, String FileName, Object obj, out String ErrorMessage)
{
try
{
FileStream fs = new FileStream(FileName, FileMode.Create);
BinaryFormatter formatter = new BinaryFormatter();
CryptoStream encStream = new CryptoStream(fs, encryptor, CryptoStreamMode.Write);
GZipStream comp = new GZipStream(encStream, CompressionMode.Compress, true);
BufferedStream bs = new BufferedStream(comp);
try
{
formatter.Serialize(bs, obj);
bs.Close();
comp.Close();
encStream.FlushFinalBlock();
encStream.Close();
fs.Close();
ErrorMessage = String.Empty;
return true;
}
catch (Exception e)
{
LogHelper.Debug("BinarySerialize出现错误:" + e.Message);
ErrorMessage = e.Message;
return false;
//throw;
}
finally
{
bs.Close();
comp.Close();
encStream.Close();
fs.Close();
}
}
catch (Exception e)
{
ErrorMessage = e.Message;
LogHelper.Debug("BinarySerialize出现错误:" + e.Message);
return false;
}
}