[Mono-list] BinaryFormatter Deserialize problem in Mono 1.0.5

Lluis Sanchez lluis@ximian.com
Mon, 20 Dec 2004 18:15:04 +0100

Let me guess... you are compiling the sender.cs + message.cs into
sender.exe, and listener.cs + message.cs into listener.exe. If you are
compiling in this way, you are doing it wrong. If you want to share the
Message class, you must compile message.cs into a dll and reference the
same dll from both applications, because the assembly name is part of
the full type name, so "Message, sender" is not the same as "Message,


On dl, 2004-12-20 at 03:56 -0500, Gregg Edghill wrote:
> Hey, I am trying to serialize an object for transfer via socket.  The
> problem I am facing is that I get the following error in Deserialize
> method invoke
> System.InvalidCastException: Cannot cast from source type to destination type.
> in <0x0018e> MultiCast.Listener:StartListening ()
> in <0x0002c> MultiCast.Server:Main (string[])
> The cast looks as follows:
> socket.Receive(b);
> MemoryStream stream1 = new MemoryStream(b);
> IFormatter f = new BinaryFormatter();
> Message md = (Message) f.Deserialize(stream1);
> I was wondering if someone could help with this because I read the
> documentation on Mono and the BinaryFormatter is supposed to be
> implemented.  Oh, almost forgot, I can serialize and deserialize to a
> filestream without a problem.
> Best regards,
> Gregg
> _______________________________________________
> Mono-list maillist  -  Mono-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list