471,353 Members | 1,680 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,353 software developers and data experts.

Serialization between two different applications.

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.

Jun 27 '08 #1
3 1580
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
"Sin Jeong-hun" <ty*******@gmail.comschreef in bericht
news:43**********************************@k1g2000p rb.googlegroups.com...
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.
Jun 27 '08 #2
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
Jun 27 '08 #3
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
Jun 27 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Steve | last post: by
2 posts views Thread by Carlo, MCP | last post: by
2 posts views Thread by Peter Duniho | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.