+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / The referenced OpenAccessContext or 'IObjectScope' is already closed (UnsynchronizedPMProxy)

The referenced OpenAccessContext or 'IObjectScope' is already closed (UnsynchronizedPMProxy)

4 posts, 0 answered
  1. Ravi
    Ravi avatar
    4 posts
    Registered:
    20 May 2014
    30 May 2014
    Link to this post
    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);}

    else
    {

    content= (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.


  2. Vassil Vassilev
     Vassil Vassilev avatar
    308 posts
    Registered:
    21 Jan 2015
    31 May 2014
    Link to this post
    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
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  3. kamii47
    kamii47 avatar
    71 posts
    Registered:
    02 Mar 2007
    31 May 2014 in reply to Vassil Vassilev
    Link to this post

    I were also getting same error in some other context as explained in http://stackoverflow.com/questions/23731156/the-referenced-openaccesscontext-or-iobjectscope-is-already-closed-unsynchron

  4. Ravi
    Ravi avatar
    4 posts
    Registered:
    20 May 2014
    01 Jun 2014 in reply to Vassil Vassilev
    Link to this post

    Thank you Vassil.

    I cached them as a Model since I am using MVC and that resolved my issue.

    Thank you.

4 posts, 0 answered