473,322 Members | 1,314 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 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 1551
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: SpaceCowboy | last post by:
I recently got into a discussion with a co-worker about using enums across a dll interface. He wanted to use chars instead, argueing that depending on compiler settings the size of an enum could...
2
by: Faisal | last post by:
Can anyone tell me if it is possible to enumerate through all the Enums within a class . I have a class with many Enums and would like to accees the Enums through an array/collection etc. I can't...
3
by: TEK | last post by:
There seems to be a bug when deserialization some classes in the .NET framework. If you try to deserialize a class that has a base class that holds a struct with a member that is implementing...
2
by: Snowman | last post by:
Suppose I have a RootObject which holds a collection of other objects. The other objects have a property (Parent) which refers back to the "parent" collection (b.t.w. my collection is based on...
0
by: Omars via DotNetMonster.com | last post by:
I am Deserializaing an XMl stream (C#). Everything works fine until I get empty tags into my Enums. For example if I have this field: Public EnumField myfield; Then I have: Public enum...
3
by: parrot toes | last post by:
Summary: I have been trying to make requests of a web service provided by Axis using a dotnet client with code generated by wsdl.exe and have been getting exceptions when trying to process the...
1
by: parrot toes | last post by:
I tried to post this question before, but there was an error when posting. I case it did get posted and in order to avoid duplication, I'll just repost a summary. I have written a dotnet client...
8
by: ashoksrini | last post by:
Hi All, I have the below requirement and would like to get some feeback from the group on the best way to implement: 1. I have WSDL defined exposing few web services. 2. We dont have a...
1
by: Dennis C. Drumm | last post by:
New for .net framework 2.0 is version tolerant serialization. To use this new feature, do I also need to use the new generics types for collections, e.g. SortedList? Thanks, Dennis
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.