Tolerant deserialization of enums

  • Thread starter Thread starter pistmaster
  • Start date Start date
P

pistmaster

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
 
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.
 
Back
Top