Error: "Detected use of SPRequest for previously closed SPWeb object. Please close SPWeb objects when you are done with all objects obtained from them, but not before." When adding WebPart

Mar 18, 2011 at 12:55 AM

Issue

I have two lists, CER and CER Inventory both have Filtered Lookup Fields.  CER contains requests to purchase new equipment and CER Inventory contains the items which compose the request.  To display the CER, I am editing DispForm.aspx for CER, to include CER Inventory list as a WebPart.  When I add the WebPart from CER Inventory, I always get the error message, "Detected use of SPRequest for previously closed SPWeb object.  Please close SPWeb objects when you are done with all objects obtained from them, but not before."

I am running as Site Administrator, with full read/write permissions to everything in the SharePoint site.

Though further exparimation, I have found that the error only occurs when the base list (CER in my case) contains a Filter Lookup Field.  Adding a Webpart List with a Filter Lookup Field to a list with out a Filter Lookup Field is successful. 

Things I have tried

From stack trace in the SharePoint Log, it looks like the exception bubbles up though Util.GetAvailableValues. 

  • I have encased the function in a try/catch block without success
  • I have ran GetAvailableValues with RunWithElevatedPrivileges without success
  • I have tried to use debugger and watch what is happening when the error occurs, but VS 2010 never breaks for this error. Likely because the exception is in Microsoft.SharePoint.SPListItemCollection.EnsureListItemsData
  • Adding a Webpart List  with a Filter Lookup Field to DespForm.aspx for list with out a Filter Lookup Field is successful.

 

Below you will find excepts from the SharePoint 2010 log file.  I have cleaned it up a little to be more readable.  Also I have changed variable names in Util.GetAvailableValues to make it more readable for me. 

Any help with this would be most appreciated.

 

Name=Request (POST:http://sp-dev-1:80/Finance/Lists/CER/DispForm.aspx?DisplayMode=Design&InitialTabId=Ribbon%2EWebPartPage&VisibilityContext=WSSWebPartPage&Source=http%3A%2F%2Fsp%2Ddev%2D1%2FFinance%2FLists%2FCER%2FAllItems%2Easpx)    d0613d2e-5a98-41eb-9536-b8deccd13d77

Detected use of SPRequest for previously closed SPWeb object.  Please close SPWeb objects when you are done with all objects obtained from them, but not before.  Stack trace:    at Microsoft.SharePoint.SPListItemCollection.EnsureListItemsData()     at Microsoft.SharePoint.SPListItemCollection.get_Count()     at Dev4Side.SP2010.FilteredLookup.Util.GetAvailableValues(FilteredLookupField filterField, HttpContext curContext)     at Dev4Side.SP2010.FilteredLookup.FilteredLookupFieldControl.Initialize()     at Dev4Side.SP2010.FilteredLookup.FilteredLookupFieldControl.OnInit(EventArgs e)     at System.Web.UI.Control.InitRecursive(Control namingContainer)     at System.Web.UI.Control.AddedControl(Control control, Int32 index)     at Microsoft.SharePoint.WebControls.FormField.CreateChildControls()     at System.Web.UI.Control.EnsureChildControls()     at Microsoft.SharePoint.WebControls.TemplateBasedControl.get_Controls()     at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)     at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)     at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)     at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)     at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)     at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)     at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)     at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)     at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)     at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)     at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)     at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)     at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)     at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)     at System.Web.UI.Control.LoadChildViewStateByID(ArrayList childState)     at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)     at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)     at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)     at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)     at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)     at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)     at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)     at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)     at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)     at System.Web.UI.Page.LoadAllState()     at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)     at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)     at System.Web.UI.Page.ProcessRequest()     at System.Web.UI.Page.ProcessRequest(HttpContext context)     at ASP.FORM_ASPX__331913002.ProcessRequest(HttpContext context)     at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()     at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)     at System.Web.HttpApplication.PipelineStepManager.ResumeSteps(Exception error)     at System.Web.HttpApplication.BeginProcessRequestNotification(HttpContext context, AsyncCallback cb)     at System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context)     at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)     at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)     at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)     at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)     

Detected use of SPRequest for previously closed SPWeb object.  Please close SPWeb objects when you are done with all objects obtained from them, but not before.  Stack trace:    at Microsoft.SharePoint.Utilities.SPUtility.GetLocalizedString(String source, String defaultResourceFile, UInt32 language)     at Microsoft.SharePoint.SPFieldLookup.get_LookupField()     at Dev4Side.SP2010.FilteredLookup.Util.GetAvailableValues(FilteredLookupField filterField, HttpContext curContext)     at Dev4Side.SP2010.FilteredLookup.FilteredLookupFieldControl.Initialize()     at Dev4Side.SP2010.FilteredLookup.FilteredLookupFieldControl.OnInit(EventArgs e)     at System.Web.UI.Control.InitRecursive(Control namingContainer)     at System.Web.UI.Control.AddedControl(Control control, Int32 index)     at MicrosoftSharePoint.WebControls.FormField.CreateChildControls()     at System.Web.UI.Control.EnsureChildControls()     at Microsoft.SharePoint.WebControls.TemplateBasedControl.get_Controls()     at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)     at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)     at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)     at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)     at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)     at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)     at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)     at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)     at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)     at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)     at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)     at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)     at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)     at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)     at System.Web.UI.Control.LoadChildViewStateByID(ArrayList childState)     at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)     at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)     at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)     at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)     at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)     at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)     at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)     at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)     at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)     at System.Web.UI.Page.LoadAllState()     at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)     at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)     at System.Web.UI.Page.ProcessRequest()     at System.Web.UI.Page.ProcessRequest(HttpContext context)     at ASP.FORM_ASPX__331913002.ProcessRequest(HttpContext context)     at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()     at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)     at System.Web.HttpApplication.PipelineStepManager.ResumeSteps(Exception error)     at System.Web.HttpApplication.BeginProcessRequestNotification(HttpContext context, AsyncCallback cb)     at System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context)     at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)     at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)     at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)     at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)

Detected use of SPRequest for previously closed SPWeb object.  Please close SPWeb objects when you are done with all objects obtained from them, but not before.  Stack trace:    at Microsoft.SharePoint.SPListItemCollection.EnsureListItemsData()     at Microsoft.SharePoint.SPListItemCollection.get_Count()     at Dev4Side.SP2010.FilteredLookup.Util.GetAvailableValues(FilteredLookupField filterField, HttpContext curContext)     at Dev4Side.SP2010.FilteredLookup.FilteredLookupFieldControl.Initialize()     at Dev4Side.SP2010.FilteredLookup.FilteredLookupFieldControl.OnInit(EventArgs e)     at System.Web.UI.Control.InitRecursive(Control namingContainer)     at System.Web.UI.Control.AddedControl(Control control, Int32 index)     at Microsoft.SharePoint.WebControls.FormField.CreateChildControls()     at System.Web.UI.Control.EnsureChildControls()     at Microsoft.SharePoint.WebControls.TemplateBasedControl.get_Controls()     at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)     at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)     at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)     at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)     at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)     at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)     at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)     at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)     at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)     at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)     at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)     at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)     at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)     at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)     at System.Web.UI.Control.LoadChildViewStateByID(ArrayList childState)     at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)     at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)     at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)     at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)     at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)     at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)     at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)     at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)     at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)     at System.Web.UI.Page.LoadAllState()     at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)     at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)     at System.Web.UI.Page.ProcessRequest()     at System.Web.UI.Page.ProcessRequest(HttpContext context)     at ASP.FORM_ASPX__331913002.ProcessRequest(HttpContext context)     at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()     at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)     at System.Web.HttpApplication.PipelineStepManager.ResumeSteps(Exception error)     at System.Web.HttpApplication.BeginProcessRequestNotification(HttpContext context, AsyncCallback cb)     at System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context)     at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)     at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)     at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)     at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)    

Coordinator
Mar 24, 2011 at 6:57 PM

this issue is caused of this bug:
http://sp2010filteredlookup.codeplex.com/discussions/251058

Please redownload the latest build and retry.

 

Let me know if this fixes your problem 

Mar 24, 2011 at 7:33 PM

Thank you vary much for your response. 

 

Your suggestion worked like a charm.

 

Thanks,

Coordinator
Mar 24, 2011 at 7:58 PM

timmckenzie,
we didn't upload correctly the updated version (1.1).

Please Consider in re-downloading it from : http://sp2010filteredlookup.codeplex.com/releases/view/63163

 

Mar 25, 2011 at 6:07 PM

The updated version, 1.1, also fixes the error. 

Thanks again.