471,075 Members | 987 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Tolerant deserialization of enums

Hi,

I have a client server application which has various messages
containing enums, ie I serialize classes of the form:

class MyClass
{
MyEnum e;
}

enum MyEnum { Unknown, Key1, Key2 }

When I add enums at the server, the clients throw an exception on
deserialization. Although if I add fields to the class everything is
fine.

What I would prefer in an ideal situation is the deserializer setting
the enum to MyEnum.Unknown. Is this possible? What is the most
graceful way to handle this situation?

Thanks

Mar 15 '07 #1
1 1481
Where are you defining the enums? Are they in an assembly that is
referenced by both the client and the server? My guess is that the answer
is no. I would take the types being serialized and share the reference to
the assembly with those serialized types between the client and server.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<pi********@googlemail.comwrote in message
news:11**********************@l77g2000hsb.googlegr oups.com...
Hi,

I have a client server application which has various messages
containing enums, ie I serialize classes of the form:

class MyClass
{
MyEnum e;
}

enum MyEnum { Unknown, Key1, Key2 }

When I add enums at the server, the clients throw an exception on
deserialization. Although if I add fields to the class everything is
fine.

What I would prefer in an ideal situation is the deserializer setting
the enum to MyEnum.Unknown. Is this possible? What is the most
graceful way to handle this situation?

Thanks

Mar 18 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

13 posts views Thread by SpaceCowboy | last post: by
2 posts views Thread by Faisal | last post: by
2 posts views Thread by Snowman | last post: by
reply views Thread by Omars via DotNetMonster.com | last post: by
3 posts views Thread by parrot toes | last post: by
1 post views Thread by Dennis C. Drumm | last post: by
reply views Thread by leo001 | 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.