例外のシリアル化と逆シリアル化
シリアル化
byte[] output; BinaryFormatter formatter = new BinaryFormatter(); MemoryStream stream = new MemoryStream(); formatter.Serialize(stream, ex); output = stream.GetBuffer(); stream.Close();
逆シリアル化
private Exception BinToException(byte[] bytes) { BinaryFormatter formatter = new BinaryFormatter(); MemoryStream stream = new MemoryStream(bytes); Exception ex = (Exception)formatter.Deserialize(stream); stream.Close(); return ex; }