代码之家  ›  专栏  ›  技术社区  ›  Janis Veinbergs

spweb处理自己并引发异常

  •  0
  • Janis Veinbergs  · 技术社区  · 15 年前

    尝试使用时 SPWeb.GetSiteData(SPSiteDataQuery) (试图将某些数据绑定到spgridview),它会向我抛出具有以下stacktrace的targetInvocationException:

    例外

      at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       at System.Web.UI.WebControls.ObjectDataSourceView.InvokeMethod(ObjectDataSourceMethod method, Boolean disposeInstance, Object& instance)
       at System.Web.UI.WebControls.ObjectDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments)
       at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback)
       at System.Web.UI.WebControls.DataBoundControl.PerformSelect()
       at System.Web.UI.WebControls.BaseDataBoundControl.DataBind()
       at System.Web.UI.WebControls.GridView.DataBind()
       at Balticovo.SharePoint.WebParts.CrossSiteDataQueryWebPart.OnLoad(EventArgs e)
    

    正在调用的方法是GetData。在使用消息调查InnerException之后 Exception from HRESULT: 0x80020009 (DISP_E_EXCEPTION)) SharePoint似乎希望发布以下资源:

       at Microsoft.SharePoint.Library.SPRequest.ReleaseResources()
       at Microsoft.SharePoint.SPRequestManager.Release(SPRequest request)
       at Microsoft.SharePoint.SPWeb.Invalidate()
       at Microsoft.SharePoint.SPWeb.Close()
       at Microsoft.SharePoint.SPWeb.Dispose()
       at Balticovo.SharePoint.Extensions.GetCrossSiteData(SPWebApplication webApp, SPCrossSiteDataQuery query)
       at Balticovo.SharePoint.TasksTableAdapter.GetData(Guid queryId, Boolean dataForOutlook)
       at Balticovo.SharePoint.TasksTableAdapter.GetData(Guid queryId)
    

    但是在调用spweb.getSiteData(spSiteDataQuery)之前,到spweb.dispose()为止的所有这些方法都不会处理任何内容,而后调用spweb.getSiteData(spSiteDataQuery)会引发异常。

    我的密码

    SPWebApplication的实例- Microsoft.SharePoint.WebControls.SPControl.GetContextWebApplication(HttpContext.Current);

    然后我在函数getCrossSiteData中执行如下操作:

    foreach (string siteUrl in query.QuerySites)
    {
       try
       {
          using (SPSite site = new SPSite(siteUrl))
          using (SPWeb web = site.OpenWeb())
          {
             DataTable dt = web.GetSiteData(query.SiteDataQuery); //Hangs here
             ....
          }
       }
    }
    

    有什么想法吗?谢谢您。

    1 回复  |  直到 15 年前
        1
  •  0
  •   Janis Veinbergs    15 年前

    结果发现,原因是某些列表的templateFeatureID属性被设置为不真正存在或以某种方式更改的模板。在我的例子中,我只是重新创建了这些列表,现在查询运行良好。

    本文发现了这一点: http://blog.myitechnology.com/2009/06/fixing-feature-guid-for-list-template.html

    只是 不要使用那个工具 为了解决这个问题,他说他正在修改内容数据库(我想是直接修改的)。这是不-不-不-不。我只是用它来看看哪些列表有问题。