HALCON多层调用可能导致无法序列化的类型:
HTuple
先压缩后序列化 序列化方法:
public bool Save(string fileName)
{
//保存对象到文本文件中(序列化)
FileStream fs = new FileStream(fileName, FileMode.Create);
MemoryStream fs1 = new MemoryStream();
try
{
//创建二进制格式化器
BinaryFormatter bf = new BinaryFormatter();
//调用序列化方法
bf.Serialize(fs1, this);
byte[] buffer = fs1.ToArray();
GZipStream ComStream = new GZipStream(fs, CompressionMode.Compress, true);
ComStream.Write(buffer, 0, buffer.Length);
ComStream.Close();
return true;
}
catch (Exception e)
{
return false;
}
finally
{
//关闭数据流
fs.Close();
fs1.Close();
}
}
导致未将对象引用设置到对象的实例错误