Hello, 

I am not sure wheter I am doing something wrong or it is a mono
issue.( According to the mono status page,
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter is
implemented)

Could anybody please tell me why the last line of code throws an
exception?

  TcpClient c ;
  try{
    c= new TcpClient("192.168.0.1",8080);
  }
  catch(SocketException e){
      ...
  }
  NetworkStream ns = c.GetStream();
  BinaryFormatter bf = new BinaryFormatter();
  PackageServerToClient p = (PackageServerToClient) bf.Deserialize(ns); << THROWS


The last line throws:

  Unhandled Exception: System.InvalidCastException: Cannot cast from source type 
  to destination type in <0x000f3> 00 .Client:Main ()


The server application had serialized the object like that:

  BinaryFormatter bf = new BinaryFormatter();
  bf.Serialize(ns,p);


and the class PackageServerToClient has been declared with the
[Serializable] attribute.


Thanks for any help.

Maurizio



_______________________________________________
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to