I built up a web application with OpenAccess as DAL and Forward-Mapping and handling scope by dealing with objects using
custom HttP-Module like it is described in Todd Anglin's blog
. It workes fine. But in one szenario I got the following problem:
I have a RadWindow with a RadGrid and a StoreButton in it. In this Grid i want to insert/update rows with PopUp-EditMode. In the PopUp is a RadComboBox which I fill with values from Database. I am dealing with the scope-object stored in HttpContext.Current.Session by HttPModule in the method: PreRequestHandlerExecute. The insert/update works fine. But if I click on the Store-Button I got the exception:
InvalidOperationException: "Object references between two different object scopes are not allowed. The object 'XYObject' is already managed by 'ObjectScopeImpl 0x3139fcd CLOSED' and was tried to be managed again by 'ObjectScopeImpl 0x22497f2 Telerik.OpenAccess.RT.ObjectScope'."
XY-Object is a persistent object whose attributes i use in the RadComboBox.
Ok I think i understand the problem. After every Request the scope is closed and before every request a new scope is initialized. So the XY-object is loaded to RadComboBox with scope 0x3130fcd. after the PopUp is closed, the scope is closed by HttpModule. By clicking on the StoreButton (PostBack) a new scope is created. Now the new scope tries to store the values to database which are loaded with the old scope (Closed).
I understand the problem, but I don't know what is the best way to resolve it.
If you need more information, please let me know. Thx for help.