Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

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.

$
0
0

I have develop a custom solution for SharePoint Foundation 2010 that provide PDF documents filled with lists data and attachemnts.

If the Customer run the solution to get the PDF we found in the ULS log following entry:

03/07/2014 12:07:20.69  w3wp.exe (0x0B10) 0x18EC 
SharePoint Foundation General                        90hv Unexpected 

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.SPFieldCollection.get_DisplayNameDict()     at Microsoft.SharePoint.SPFieldCollection.GetFieldByDisplayName(String strDisplayName, Boolean bThrowException)     at Microsoft.SharePoint.SPFieldCollection.GetField(String strName, Boolean bThrowException)     at Microsoft.SharePoint.SPListItem.GetValue(String strName, Boolean bThrowException)     at Microsoft.SharePoint.SPListItem.get_Item(String fieldName)    

at ECM_PDF_Excel.ListClicked.GetECOs(Dictionary`2 searchedEC... e918ecd4-7ed6-44bb-9e4f-d764586a2f79 ...RECONumber)    at ECM_PDF_Excel.PDF.Create()     at ECM_PDF_Excel.Layouts.ECM_PDF_Excel.ECMPDFExcel.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 f... e918ecd4-7ed6-44bb-9e4f-d764586a2f79
03/07/2014 12:07:20.69* w3wp.exe (0x0B10)                        0x18EC SharePoint Foundation         General                        90hv Unexpected ...lags)     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)   e918ecd4-7ed6-44bb-9e4f-d764586a2f79

We check the method

        /// <summary>
        /// Returns the ECOs in a Dictionary: ECO Number, Suffix
        /// </summary>
        /// <param name="searchedECRECONumber">Dictionary, with the search ECR/ECO Number</param>
        /// <returns>Dictionary ECO Number, Suffix</returns>
        public static Dictionary<string, string> GetECOs(Dictionary<String, String> searchedECRECONumber)
        {
            SPSite siteContx = SPContext.Current.Site;
            SPWeb webContx = siteContx.RootWeb;

            Dictionary<string, string> listECOs = new Dictionary<string, string>();
            string ecoNumber = string.Empty;
            string ecoSuffix = string.Empty;

            if (searchedECRECONumber.ContainsKey(ConstantData.listClickedECONumberDictionary))
            {
                ecoNumber = searchedECRECONumber[ConstantData.listClickedECONumberDictionary];
            }
            else
            {
                return listECOs;
            }

            // Ich suche die ECO Nummber bei gegebener ECR Nummer
            // Ich brauche den Listen Namen der in den Spalten Realtion ECR Number & Realtion ECO Number einen Wert hat
            SPList dataList = webContx.Lists.TryGetList(ConstantData.listName_ECMExcelTemplateDataLists);
            if (dataList != null)
            {
                SPListItemCollection dataListItems = webContx.Lists.TryGetList(ConstantData.listName_ECMExcelTemplateDataLists).Items;
                foreach (SPItem dataListItem in dataListItems)
                {
                    Object relationECRColumnName = (String)dataListItem[ConstantData.listFieldName_ECMExcelTemplateDataLists_RelationECRNumber];
                    Object relationECOColumnName = (String)dataListItem[ConstantData.listFieldName_ECMExcelTemplateDataLists_RelationECONumber];
                    if (relationECRColumnName != null && relationECOColumnName != null)
                    {
                        // Ich habe den Listennamen gefunden in dem Spalten Realtion ECR Number & Realtion ECO Number einen Wert haben
                        string searchedListName = (String)dataListItem[ConstantData.listFieldName_ECMExcelTemplateDataLists_Title];
                        string searchedECOSuffixColumnName = (String)dataListItem[ConstantData.listFieldName_ECMExcelTemplateDataLists_RelationECONumber];
                        // Get the List from variable listName
                        listECOs = GetECOsDictionary(searchedListName, searchedECOSuffixColumnName, ecoNumber, relationECOColumnName);
                    }
                }
            }

            return listECOs;
        }

- What take we wrong?
- How can we avoid this message?

Regards
Jonnyenglisch


Ralf Happe - Christobal Colón N° 1 ES 07670 Portocolom Tel.: +34 6961 0375 7 @: service@ralfhappe.com Skype: ralfhappe msm: ralfhappe@hotmail.com www.ralfhappe.com ralfhappe | soluciónes


Viewing all articles
Browse latest Browse all 11571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>