0

I'm trying to deserializing to DataFromServerToClient object that I designed. but It doesn't work. I said sirialized keyword to every classes that it has as fields. exception message is

version=1.0.0.0 culture=neutral publickeytoken=null

what am I supposed to do then? Do I have to define methods as property?

===================================================================
sockServer.Receive(buffer);

formatter = new BinaryFormatter();

MemoryStream ms = new MemoryStream(buffer);

dataFromServerToClient = (DataFromServerToClient)formatter.Deserialize(ms);
===================================================================
Steve Blackwell
  • 5,904
  • 32
  • 49
  • Is the type of object sent over from the client to server in a different library, and the library is referenced by both the client and the server? – gilmishal May 06 '14 at 15:40
  • 1
    This is not a proper exception message. Please post the entire message. Also, a simple `sockServer.Receive(buffer);` may *not* get all the data sent by the server, as the data may be fragmented so that you need to call `Receive` multiple times until you get all the data. You need to come up with a sort of protocol where you define for example that the first 8 bytes give you the byte array length to be received and then you call `Receive` until all the bytes were read. It is a common misconception that because you `Send` a buffer to the socket in a single call a single `Receive` is enough. – Thorsten Dittmar May 06 '14 at 15:44

0 Answers0