Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enum not serializing

Tags:

c#

wcf

msmq

I have a WCF service. it is bound to an MSMQ but that is not the issue here. I can serialize an object which has a base class and an interface implemented in the base class and the concrete class derives from the base class - this works fine.

however, when I have an enum in the base class and I set that value, then after it being deserialized/read from the MSMQ, that value is still set to the default value (i.e not the one set manually in code)

any ideas whats going on? I even marked the enum as a DataContract and also each of the Enum members with an EnumMember attribute.

how can I serialize enums?

like image 814
Ahmed ilyas Avatar asked May 14 '12 19:05

Ahmed ilyas


Video Answer


1 Answers

The property was protected. set it to Public and viola - serialized the enum property. Kinda bad as the property resides in a bass class....rather have it protected

like image 178
Ahmed ilyas Avatar answered Sep 28 '22 09:09

Ahmed ilyas