Question

I have a class marked as CollectionDataContract which has a enum member. When I place an object of this class in Appfabric, I am through. When I get it back from App fabric, it does not deserialize the enum member. But I am not sure if the enum has been missed out in Serialization part itself.

Please do help.

If you need more information let me know.

Thanks.

[CollectionDataContract]
public partial class RuleConditionList : List<IRuleCondition>, IRuleCondition
{
   public LogicalOperator Operator;
}

where LogicalOperator is an enum

Was it helpful?

Solution 2

Any data member in a class marked with Collection data contract cannot be serialized by NetdataContractSerializer which is the serailization technique used by App fabric for storing data.

To make things work we have two options:

  1. Make a wrapper for RuleConditionList
  2. Instead of Inheriting from List, make it as a property and change the attribute as DataContract.

OTHER TIPS

I think there is a problem when serializing/deserializing your object. AppFabric uses the NetDataContractSerializer class for serialization before storing the items in the cache.

You can use the Net­Dat­a­Con­tract­Se­ri­al­izer on any type which are marked with the Dat­a­Con­trac­tAt­tribute or Seri­al­iz­ableAt­tribute, or types that imple­ment the ISe­ri­al­iz­able interface.

So depending and your object, there should be something wrong like a private type, a private field, a missing attibute, ...

Edit

You should add DataMember to your field.

[DataMember]
public LogicalOperator Operator; 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top