G
Guest
I am serializing the following struct
public struct Tan
int x
int y
using the following code
BinaryFormatter formatter = new BinaryFormatter()
MemoryStream mStream = new MemoryStream()
formatter.Serialize(mStream, tank)
and sending this to a UdpClient on a different machine using this code
IPEndPoint remoteEP = new IPEndPoint(IPAddress.Parse("xxx.xxx.xxx.xxx"), 11000)
UdpClient client = new UdpClient()
client.Send(mStream.GetBuffer(), (int)mStream.Length, remoteEP)
Now then, my client is receiving the packet via the following cod
IPEndPoint localEP = new IPEndPoint(IPAddress.Parse("xxx.xxx.xxx.xxx"), 11000)
UdpClient client = new UdpClient(localEP)
IPEndPoint remoteEP = new IPEndPoint(IPAddress.Any, 11000)
BinaryFormatter formatter = new BinaryFormatter()
MemoryStream mStream = new MemoryStream()
byte[] message = client.Receive(ref remoteEP)
mStream.Write(message, 0, message.Length)
mStream.Position = 0
At this point, I compare the mStream that I sent to the mStream that arrived (breakpoints) and I see that they are in fact the same size, have the same bytes writting to them, etc. - they look absultely correct. However, the following command causes the error in question
Tank tank = (Tank)formatter.Deserialize(mStream)
//The Tank structure is declared both on the server and the client and they look the exact same, etc . .
I get the following error
System.Runtime.Serialization.SerializationException: Cannot find the assembly MyClient, Version=1.0.1600.39535, Culture=neutral, PublicKeyToken=null
at System.Runtime.Serialization.Formatters.Binary.BinaryAssemblyInfo.GetAssembly(
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.GetType(Binar
etc.... etc.... etc...
MyClient is the assembly that SENT the original packet. Why is the MyServer assembly (the packet receiver) throwing an error about the sending machines assembly? I'm only trying to serialize a class and I'm baffled as to why assembly information has anything to do with deserializing it - but then again, I'm new to Serialization :
I've been struggling with this now for 3 days and my deadline is tommorrow. I sure hope I can find an answer soon :
Thanks in advance for any replies
Rob
public struct Tan
int x
int y
using the following code
BinaryFormatter formatter = new BinaryFormatter()
MemoryStream mStream = new MemoryStream()
formatter.Serialize(mStream, tank)
and sending this to a UdpClient on a different machine using this code
IPEndPoint remoteEP = new IPEndPoint(IPAddress.Parse("xxx.xxx.xxx.xxx"), 11000)
UdpClient client = new UdpClient()
client.Send(mStream.GetBuffer(), (int)mStream.Length, remoteEP)
Now then, my client is receiving the packet via the following cod
IPEndPoint localEP = new IPEndPoint(IPAddress.Parse("xxx.xxx.xxx.xxx"), 11000)
UdpClient client = new UdpClient(localEP)
IPEndPoint remoteEP = new IPEndPoint(IPAddress.Any, 11000)
BinaryFormatter formatter = new BinaryFormatter()
MemoryStream mStream = new MemoryStream()
byte[] message = client.Receive(ref remoteEP)
mStream.Write(message, 0, message.Length)
mStream.Position = 0
At this point, I compare the mStream that I sent to the mStream that arrived (breakpoints) and I see that they are in fact the same size, have the same bytes writting to them, etc. - they look absultely correct. However, the following command causes the error in question
Tank tank = (Tank)formatter.Deserialize(mStream)
//The Tank structure is declared both on the server and the client and they look the exact same, etc . .
I get the following error
System.Runtime.Serialization.SerializationException: Cannot find the assembly MyClient, Version=1.0.1600.39535, Culture=neutral, PublicKeyToken=null
at System.Runtime.Serialization.Formatters.Binary.BinaryAssemblyInfo.GetAssembly(
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.GetType(Binar
etc.... etc.... etc...
MyClient is the assembly that SENT the original packet. Why is the MyServer assembly (the packet receiver) throwing an error about the sending machines assembly? I'm only trying to serialize a class and I'm baffled as to why assembly information has anything to do with deserializing it - but then again, I'm new to Serialization :
I've been struggling with this now for 3 days and my deadline is tommorrow. I sure hope I can find an answer soon :
Thanks in advance for any replies
Rob