This is a migrated thread and some comments may be shown as answers.

cant cache Objects that I read by ORM

3 Answers 82 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Sinan
Top achievements
Rank 1
Sinan asked on 30 Sep 2009, 08:30 PM
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;  




3 Answers, 1 is accepted

Sort by
0
Accepted
Damyan Bogoev
Telerik team
answered on 02 Oct 2009, 01:21 PM
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.
0
Richard
Top achievements
Rank 1
answered on 08 Apr 2011, 08:52 PM
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.
0
Alexander
Telerik team
answered on 13 Apr 2011, 05:09 PM
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.

Greetings,
Alexander
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
Tags
Development (API, general questions)
Asked by
Sinan
Top achievements
Rank 1
Answers by
Damyan Bogoev
Telerik team
Richard
Top achievements
Rank 1
Alexander
Telerik team
Share this question
or