Serialization between two different applications.

S

Sin Jeong-hun

Hi.

There are a server and a client, and I need to exchange "Message"
objects between them. The class Message included in both applications
has the exact signature (namespace, all fields, methods, etc. In fact,
I copied the same file into both projects) But serialzing from one
side and deserializing on the other side causes assembly not found
exception. I've searched the internet and found some article that said
I need to implement ISerializable to work around, but after trying
that, I think that might only work on the same application
(assembly).

What should I do? I know the easiest solution to this is to move the
class "Message" into a separate assembly and refer to it in both
applications (server and client), but is this the only way? The
Message classes in the two applications are exactly the same (again,
copy and paste) , can't I somehow convert the deserialized object into
Message object, by force? I would like to hear how you deal with this
kind of situation, because I think probably many people already have
encountered with this problem before. Thank you.
 
C

Cor Ligthert[MVP]

Sin Jeong-hun,

You have made from your Message a seperated DLL library (or put it in a for
you common library).

Then you could use the class on both sides to serialize and deserialize by
just referencing to it and using it..

Cor

Yo
 
M

Marc Gravell

As an alternative - is xml serialization an option? Both XmlSerializer
and DataContractSerializer should be perfectly happy with this setup.
The latter has the advantage that it can [optionally, not by default]
cope with full graphs, where-as XmlSerializer is limited to trees
[i.e. no loops back to objects that have already been serialized in
the same branch].

Xml also has a few tricks when it comes to evoloving the type, and xml
compresses very well with things like GZip if data volume is an issue.

Marc
 
M

Marc Gravell

I forgot to add; "serialization surrogates" may be an option, but
frankly it gets very messy very quickly. Not my first choice...

(my first choice would be assembly sharing ;-p)

Marc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top