cant cache Objects that I read by ORM

4 posts, 1 answers
  1. Sinan
    Sinan  avatar
    6 posts
    Member since:
    Jul 2009

    Posted 30 Sep 2009 Link to this post

    I have a list of object that I read them from database using ORM
    when repeater try to read the cached copy of the an error occure saying , IObject scope already closed

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: Telerik.OpenAccess.Exceptions.InvalidOperationException: The 'IObjectScope' is already closed

    Source Error:

    Line 32:         public string Title
    Line 33:         {
    Line 34:             get { return title; }
    Line 35:             set { this.title = value; }
    Line 36:         }

    here is the code
      IObjectScope scope = ScopeUtility.GetScope(); 
                if (HttpContext.Current.Cache["regions"] != null
                    return (List<ProductRegion>)HttpContext.Current.Cache["regions"]; 
                List<ProductRegion> list = (from fn in scope.Extent<ProductRegion>() select fn).ToList(); 
                HttpContext.Current.Cache.Insert("regions", list.ToList()); 
                return list;  

  2. Answer
    Damyan Bogoev
    Damyan Bogoev avatar
    581 posts

    Posted 02 Oct 2009 Link to this post

    Hello Sinan ,

    We would like to ask you for additional information regarding what the ScopeUtility.GetScope() method does? A possible problem could be if you are disposing the IObjectScope instance in this method.  We would suggest you to follow our guidelines on object scope management described in those two articles:
    Best Practices in web development with OpenAccess Best Practices in web development with OpenAccess - Part Two
    Hope you will find this information helpful.

    Best wishes,
    Damyan Bogoev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft banner
  4. Richard
    Richard avatar
    4 posts
    Member since:
    Mar 2011

    Posted 08 Apr 2011 Link to this post

    I know this is an old thread, but I am having the same error as stated by Sinan. When I cache and object in System.Web.HttpRuntime.Cache.
    I am passing the scope down from our basepage.
  5. Alexander
    Alexander avatar
    727 posts

    Posted 13 Apr 2011 Link to this post

    Hi Richard,

    We found a problem in the Q1 2011 release which could lead to such behavior. I would suggest you to download the latest service pack (version 2011.1 411) which contains the fix for this issue.
    If the problem remains, please let us know and provide the code that is causing the exception, so we can investigate further.

    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top