public object Deserialize(byte[] bytes)
{
if (bytes == null)
{
throw new ArgumentNullException("bytes");
}
if (bytes.Length == 0)
{
throw new ArgumentException("The provided byte array cannot be deserialized; it contains no data");
}
using (var stream = new MemoryStream(bytes))
{
var formatter = new BinaryFormatter();
return formatter.Deserialize(stream);
}
}