locked
Azure Cache session and Entity Framewrok causing problem when List or collection of entity is stored in session RRS feed

  • Question

  • The EntityCollection object could not be serialized. This type of object cannot be serialized when the RelationshipManager belongs to an entity object that does not implement IEntityWithRelationships.

    .............

       at System.Runtime.Serialization.ClassDataContract.WriteXmlValue(XmlWriterDelegator xmlWriter, Object obj, XmlObjectSerializerWriteContext context)
       at System.Runtime.Serialization.NetDataContractSerializer.InternalWriteObjectContent(XmlWriterDelegator writer, Object graph, DataContract contract, Hashtable surrogateDataContracts)
       at System.Runtime.Serialization.NetDataContractSerializer.InternalWriteObject(XmlWriterDelegator writer, Object graph)
       at System.Runtime.Serialization.XmlObjectSerializer.WriteObjectHandleExceptions(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver)
       at System.Runtime.Serialization.XmlObjectSerializer.WriteObject(XmlDictionaryWriter writer, Object graph)
       at Microsoft.ApplicationServer.Caching.NetDataContractCacheObjectSerializer.Serialize(Stream stream, Object value)
       at Microsoft.ApplicationServer.Caching.DataCacheObjectSerializationProvider.SerializeUserObject(Object userObject, Boolean isCompressionEnabled, ValueFlagsVersion flagsType)
       at Microsoft.ApplicationServer.Caching.SocketClientProtocol.SerializeValue(Object obj)
       at Microsoft.ApplicationServer.Caching.SocketClientProtocol.Upsert(VelocityPacketType type, String key, Object value, DataCacheItemVersion oldVersion, TimeSpan timeout, DataCacheTag[] tags, String region, IMonitoringListener listener)
       at Microsoft.ApplicationServer.Caching.SocketClientProtocol.Put(String key, Object value, DataCacheItemVersion oldVersion, TimeSpan timeout, DataCacheTag[] tags, String region, IMonitoringListener listener)
       at Microsoft.ApplicationServer.Caching.DataCache.InternalPut(String key, Object value, DataCacheItemVersion oldVersion, TimeSpan timeout, DataCacheTag[] tags, String region, IMonitoringListener listener)
       at Microsoft.ApplicationServer.Caching.DataCache.<>c__DisplayClass2e.<Put>b__2d()
       at Microsoft.ApplicationServer.Caching.MonitoringListenerFactory.EmptyListener.Microsoft.ApplicationServer.Caching.IMonitoringListener.Listen[TResult](Func`1 innerDelegate)
       at Microsoft.ApplicationServer.Caching.DataCache.Put(String key, Object value, TimeSpan timeout)
       at Microsoft.Web.DistributedCache.DataCacheWrapper.Put(String key, Object value, TimeSpan timeout)
       at Microsoft.Web.DistributedCache.DataCacheForwarderBase.<>c__DisplayClass13.<Put>b__12()
       at Microsoft.Web.DistributedCache.DataCacheForwarderBase.<>c__DisplayClass31`1.<PerformCacheOperation>b__30()
       at Microsoft.Web.DistributedCache.DataCacheRetryWrapper.PerformCacheOperation(Action action)
       at Microsoft.Web.DistributedCache.DataCacheForwarderBase.PerformCacheOperation[TResult](Func`1 func)
       at Microsoft.Web.DistributedCache.DataCacheForwarderBase.Put(String key, Object value, TimeSpan timeout)
       at Microsoft.Web.DistributedCache.AsyncOperationDispatcherFactory.AsyncOperationDispatcher.<>c__DisplayClassf.<PutAsync>b__e(IDataCache dataCache)

       at Microsoft.Web.DistributedCache.AsyncOperationDispatcherFactory.AsyncOperationDispatcher.<>c__DisplayClassa.<>c__DisplayClassc.<.ctor>b__3()
       at System.Threading.Tasks.Task.Execute()

    I am trying to store a Entity object which has a collection of Different entity in it. 

    public class EnttiyA

    {

    public int A {get;set;}

    public int B{get;set;}

    public virtual IList<EnttityC> listc {get;set;}

    }

    public class EntityC

    {

    public  int A {get;set;}

    public int B {get;set;}

    public DateTime createddate {get;set;}

    }

    I am getting this error when i change my session management to Azures Co-located Cache. Else My entity where working fine before it. So any suggestions.

    It might be mapping issue of Entities but not sure hope some expert here can help me in this.

    Saturday, December 1, 2012 3:07 PM

Answers

All replies