zoukankan      html  css  js  c++  java
  • SharePoint How To:定位错误:“An SPRequest object was not disposed .."

    我们的Sharepoint程序有时泄露了很多SPWeb,SPSite对象,SharePoint日志中就会有很多错误信息,如下:

       

    An SPRequest object was not disposed before the end of this thread. To avoid wasting system resources, dispose of this object or its parent (such as an SPSite or SPWeb) as soon as you are done using it. This object will now be disposed. Allocation Id: {5E41622E-AFA6-44E4-AAB3-809A70D39CCA} To determine where this object was allocated, set Microsoft.SharePoint.Administration.SPWebService.ContentService.CollectSPRequestAllocationCallStacks = true(线索).

       

    如果您细心地话,您会发现上面日志中提到了一个参数,按照要求设置后就可以看到完整的CallStacks

       

    An SPRequest object was not disposed before the end of this thread. To avoid wasting system resources, dispose of this object or its parent (such as an SPSite or SPWeb) as soon as you are done using it. This object will now be disposed. Allocation Id: {A635DEED-3786-40C7-BA42-6D3E3CB4571B} This SPRequest was allocated

    at

    at Microsoft.SharePoint.Library.SPRequest..ctor()

    at Microsoft.SharePoint.SPGlobal.CreateSPRequestAndSetIdentity(SPSite site, String name, Boolean bNotGlobalAdminCode, String strUrl, Boolean bNotAddToContext, Byte[] UserToken, String userName, Boolean bIgnoreTokenTimeout, Boolean bAsAnonymous)

    at Microsoft.SharePoint.SPWeb.InitializeSPRequest()

    at Microsoft.SharePoint.SPFieldCollection.EnsureFieldsSafeArray(Boolean bGetFullXML)

    at Microsoft.SharePoint.SPFieldCollection.get_DisplayNameDict()

    at Microsoft.SharePoint.SPFieldCollection.GetFieldByDisplayName(String strDisplayName, Boolean bThrowException)

    at SharePointBoost.Workflow.Common.WorkflowRepository.GetItems(SPList list, Hashtable condition)

    at SharePointBoost.Workflow.Common.WorkflowRepository.GetWorkflow(String workflowId, VersionType version)

    at SharePointBoost.Workflow.Layouts.ApplicationPages.WorkflowDesigner.CreateWorkflowDesigner(String workflowID, VersionType version)

    at SharePointBoost.Workflow.Layouts.ApplicationPages.WorkflowDesigner.Page_Load(Object sender, EventArgs e)

    at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)

    at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)

    at System.Web.UI.Control.OnLoad(EventArgs e)

    at Microsoft.SharePoint.WebControls.UnsecuredLayoutsPageBase.OnLoad(EventArgs e)

    at Microsoft.SharePoint.WebControls.LayoutsPageBase.OnLoad(EventArgs e)

    at System.Web.UI.Control.LoadRecursive()

    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._layouts_sharepointboost_workflow_workflowdesigner_aspx.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)

       

    运行下面的的Power Shell代码设置Microsoft.SharePoint.Administration.SPWebService.ContentService.CollectSPRequestAllocationCallStacks。(如果没用过Power Shell,参考:http://technet.microsoft.com/en-us/library/ee176949.aspx 

    Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

    [System.Reflection.Assembly]::LoadFile($Env:CommonProgramFiles+"\Microsoft Shared\Web Server Extensions\14\ISAPI\Microsoft.SharePoint.dll") | out-null

       

    # Get Content Service of the farm

    $contentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService

       

    # Display and change the setting of property "CollectSPRequestAllocationCallStacks"

    write-host "Current: " $contentService.CollectSPRequestAllocationCallStacks

    $contentService.CollectSPRequestAllocationCallStacks = $true

    $contentService.Update()

       

    write-host " New: " $contentService.CollectSPRequestAllocationCallStacks

       

       

       

       

       

  • 相关阅读:
    sqlserver数据导入问题:报错“对COM组件的调用返回了错误HRESULT E_FAIL”
    删除文件夹提示”该项目不在请确认该项目位置“
    delphi三层DCOM架构
    sqlserver 将店铺表转换成可以用in查询的字符串
    Delphi如何获取一个字符串再另一个字符串中最后一次出现的位置
    c# 通过地址下载流然后保存文件到本地
    使用SQL语句清空数据库所有表的数据
    SqlServer 查询的时候过滤条件有参数导致速度很慢的问题-参数嗅探
    delphi和C# 保存exe文件到数据库
    DELPHI 多线程(TThread类的实现)
  • 原文地址:https://www.cnblogs.com/osamede/p/2222363.html
Copyright © 2011-2022 走看看