有一个excel插件,它与我正在处理的主应用程序进行通信。我将序列化对象发送到插件,我似乎无法反序列化该对象。我得到如下所示的此异常。请帮忙。
该对象已成功发送,但问题是将其反序列化。 这是我从
收到对象的代码public void PipeIn(string sender, MessageType messageType, byte[] eventClass)
{
if (DataReady != null)
{
MemoryStream stream = new MemoryStream(eventClass);
try
{
var deserializedObj = _binFormatter.Deserialize(stream);
DataReady(sender, messageType, deserializedObj);
}
catch (Exception _e)
{
throw;
}
finally
{
stream.Close();
}
}
}
这是我用来序列化对象的方法
var stream = new MemoryStream();
byte[] objectByteArr = null;
try
{
//Serialize the object into the stream
_binFormatter.Serialize(stream, eventType);
//Copy the bytes from the stream to the byte array
objectByteArr = stream.ToArray();
if (objectByteArr.Length >= 536870912)
{
MessageBox.Show("The Data Exceeds the max size of 536870912", "Too Big", MessageBoxButtons.OK,
MessageBoxIcon.Exclamation);
}
}
catch (Exception _e)
{
}
finally
{
stream.Close();
}