المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Problem during deserialization



C# Programming
04-09-2009, 02:40 PM
Hi All,

I am unable to deserialize the byte array to the object of structure on another machine,when i send it through TCP/IP by socket then there is no problem in serialization.,but problem occurs at the other side during deserialization.

It shows the error something like "unable to find assembly....."

I am using the following code....

private byte[] ObjectToByteArray(Object obj)
{
if (obj == null)
return null;
BinaryFormatter bf = new BinaryFormatter();
MemoryStream ms = new MemoryStream();
bf.Serialize(ms, obj);
return ms.ToArray();
}
// Convert a byte array to an Object
private Object ByteArrayToObject(byte[] arrBytes)
{
MemoryStream memStream = new MemoryStream(arrBytes);
BinaryFormatter binForm = new BinaryFormatter();
memStream.Position = 0;
//memStream.Write(arrBytes, 0, arrBytes.Length);
// memStream.Seek(0, SeekOrigin.Begin);
Object obj = (Object)binForm.Deserialize(memStream);
return obj;
}



Please help,it is urgent....


Regards
Lalit Narayan