views:

826

answers:

3

I'm Serializing an ArrayList to a binary file in order to send it across TCP/IP. The serialized file is created by the server and I hope to be able to deserialize it with the client that I'm writing at the moment.

However, when the client attempts to deserialize it throws a SerializationException because it can't find the assembly (presumably) which serialized the file to begin with.

How do I get around this?

+2  A: 

Does your arraylist contain custom data type (i.e. your own classes)?

The arraylist won't be deserialized unless the code running the deserialize has access to all of the classes contained within the arraylist.

ck
+1  A: 

If you are using binary serialization, the client will need to have access to the DLL that contains the type that you are serializing in the ArrayList. I guess I don't really know about your setup to describe how that should be done but that's the gist of it.

If you use something like xml serialization (either using XmlSerializaer or DataContractSerializer), you will be able to produce Xml. You can duplicate the object code on both server/client side if you are truly unable to share the assembly.

siz
A: 

What is the data that you are trying to send? And how are you serializing it? If you are using BinaryFormatter, then the assembly declaring any custom types must be at both ends.

Note that BinaryFormatter has a range of issues with serialization across systems (including between different versions of the same system). You may want to look at other serializers, such as DataContractSerializer, or protobuf-net (for efficient, cross-platform binary transfer).

Marc Gravell