当尝试使用SPWeb.GetSiteData(SPSiteDataQuery) (试图将一些数据绑定到SPGridView)时,它抛给我一个带有以下堆栈跟踪的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。在使用message Exception from HRESULT: 0x80020009 (DISP_E_EXCEPTION))研究了InnerException之后,看起来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.Dispose()之前,所有这些方法在我调用SPWeb.GetSiteData(SPSiteDataQuery)之前都不会处理任何东西,然后它会抛出一个异常。
我的代码
我得到的SPWebApplication实例如下- Microsoft.SharePoint.WebControls.SPControl.GetContextWebApplication(HttpContext.Current);
然后我在function 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
....
}
}
}有什么想法吗?谢谢。
发布于 2009-09-21 13:34:21
事实证明,原因是对于某些列表,TemplateFeatureId属性被设置为实际上不存在的模板,或者以某种方式进行了更改。在我的例子中,我只是重新创建了这些列表,现在查询运行得很好。
通过这篇文章发现了这一点:http://blog.myitechnology.com/2009/06/fixing-feature-guid-for-list-template.html
只是没有使用工具来解决这个问题-他说他正在修改内容数据库(我想是直接修改)。这可是个禁忌。我只是用它来查看哪些列表有问题。
https://stackoverflow.com/questions/1454105
复制相似问题