public static byte[] Wrap (Exception exception)
{
byte[] data;
// Serialize the exception using a binary format
using (MemoryStream stream = new MemoryStream()) {
BinaryFormatter formatter = new BinaryFormatter ();
formatter.Serialize (stream, exception);
data = stream.ToArray ();
}
return data;
}
}