The referenced OpenAccessContext or 'IObjectScope' is already closed (UnsynchronizedPMProxy)
I am trying to Cache a list of Telerik.Sitefinity.DynamicModules.Model.DynamicContent and I get Telerik,OpenAccess.Exception.InvalidOperationException.
var content= new List<Telerik.Sitefinity.DynamicModules.Model.DynamicContent>(); if (System.Web.HttpContext.Current.Cache["content"] == null)
allMyAccounts = dmm.GetDataItems(Content).Where(s => s.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live).ToList(); System.Web.HttpContext.Current.Cache.Add("content", content, null, System.Web.Caching.Cache.NoAbsoluteExpiration, new TimeSpan(0, 15, 0), System.Web.Caching.CacheItemPriority.NotRemovable, null);
elsecontent= (List<Telerik.Sitefinity.DynamicModules.Model.DynamicContent>)System.Web.HttpContext.Current.Cache["content"];
When the data is not cached yet, I get the results fine. But getting the results back from the cache is an issue.
And I get
The referenced OpenAccessContext or 'IObjectScope' is already closed (UnsynchronizedPMProxy).
Thanks in advance.
Hello Ravi,
This issue is caused by a query pulling dynamic items out of cache. As dynamic items cannot exist without the DynamicManager, the .Net garbage collector releases the manager from the memory (as it is not used by your code anymore) and then if you pull those items from cache you will get "IObjectScope is already closed".
Keeping those items in a List, will prevent the garbage collector from disposing the DynamicManager.
Regards,
Vassil Vassilev
Telerik
I were also getting same error in some other context as explained in stackoverflow.com/.../the-referenced-openaccesscontext-or-iobjectscope-is-already-closed-unsynchron
Thank you Vassil.
I cached them as a Model since I am using MVC and that resolved my issue.
Thank you.