SharePoint 2010 - 读取列表项时出错“无法完成此操作。请再试一次。”

发布于 2024-10-16 18:51:24 字数 7328 浏览 2 评论 0原文

我有一个部署列表的 SharePoint 2010 Farm 解决方案,以及一个从该列表读取的 Web 部件。实际上它的作用不止于此,但我无法跳过“阅读列表”部分。

我能够成功查询列表并取回 SPListItemCollection,但是当我尝试循环遍历项目时,我收到这个完全不明确的错误“无法完成此操作。请重试。”下面是完整的堆栈跟踪:

[COMException (0x80004005): Cannot complete this action.

Please try again.<nativehr>0x80004005</nativehr><nativestack></nativestack>]
   Microsoft.SharePoint.Library.SPRequestInternalClass.GetListItemDataWithCallback2(IListItemSqlClient pSqlClient, String bstrUrl, String bstrListName, String bstrViewName, String bstrViewXml, SAFEARRAYFLAGS fSafeArrayFlags, ISP2DSafeArrayWriter pSACallback, ISPDataCallback pPagingCallback, ISPDataCallback pPagingPrevCallback, ISPDataCallback pFilterLinkCallback, ISPDataCallback pSchemaCallback, ISPDataCallback pRowCountCallback, Boolean& pbMaximalView) +0
   Microsoft.SharePoint.Library.SPRequest.GetListItemDataWithCallback2(IListItemSqlClient pSqlClient, String bstrUrl, String bstrListName, String bstrViewName, String bstrViewXml, SAFEARRAYFLAGS fSafeArrayFlags, ISP2DSafeArrayWriter pSACallback, ISPDataCallback pPagingCallback, ISPDataCallback pPagingPrevCallback, ISPDataCallback pFilterLinkCallback, ISPDataCallback pSchemaCallback, ISPDataCallback pRowCountCallback, Boolean& pbMaximalView) +256

[SPException: Cannot complete this action.

Please try again.]
   Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx) +27257906
   Microsoft.SharePoint.Library.SPRequest.GetListItemDataWithCallback2(IListItemSqlClient pSqlClient, String bstrUrl, String bstrListName, String bstrViewName, String bstrViewXml, SAFEARRAYFLAGS fSafeArrayFlags, ISP2DSafeArrayWriter pSACallback, ISPDataCallback pPagingCallback, ISPDataCallback pPagingPrevCallback, ISPDataCallback pFilterLinkCallback, ISPDataCallback pSchemaCallback, ISPDataCallback pRowCountCallback, Boolean& pbMaximalView) +27639062
   Microsoft.SharePoint.SPListItemCollection.EnsureListItemsData() +4145
   Microsoft.SharePoint.SPListItemCollection.GetEnumerator() +146
   X.CBAS.TargetedNav.TargetedNav.TargetedNav.getUrlsForUser() +433
   X.CBAS.TargetedNav.TargetedNav.TargetedNav.CreateChildControls() +437
   System.Web.UI.Control.EnsureChildControls() +146
   X.CBAS.TargetedNav.TargetedNav.TargetedNav.OnLoad(EventArgs e) +140
   System.Web.UI.Control.LoadRecursive() +66
   System.Web.UI.Control.LoadRecursive() +191
   System.Web.UI.Control.LoadRecursive() +191
   System.Web.UI.Control.LoadRecursive() +191
   System.Web.UI.Control.LoadRecursive() +191
   System.Web.UI.Control.LoadRecursive() +191
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2428

我已经多次查看了列表定义,它看起来很合理,就像我所看到的 Web 部件代码一样。

列表定义:

<ContentTypes>
  <ContentTypeRef ID="0x0105">
    <Folder TargetName="Link" />
  </ContentTypeRef>
  <ContentTypeRef ID="0x0120" />
</ContentTypes>
<Fields>
  <Field ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" ReadOnly="TRUE" Required="FALSE" Hidden="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Title"></Field>
  <Field ID="{82642ec8-ef9b-478f-acf9-31f7d45fbc31}" Name="LinkTitle" Hidden="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="LinkTitle"></Field>
  <Field ID="{bc91a437-52e7-49e1-8c4e-4698904b2b6d}" Name="LinkTitleNoMenu" Hidden="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="LinkTitleNoMenu"></Field>
  <Field ID="{081c6e4c-5c14-4f20-b23e-1a71ceb6a67c}" Name="DocIcon" DisplaceOnUpgrade="TRUE" DisplayName="$Resources:core,Type;" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="DocIcon"></Field>
  <Field ID="{503f1caa-358e-4918-9094-4a2cdc4bc034}" Name="Edit" DisplayName="$Resources:core,Edit;" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Edit"></Field>
  <Field ID="{c29e077d-f466-4d8e-8bbe-72b66c5f205c}" Type="URL" Name="URL" DisplayName="$Resources:core,URL;" Required="TRUE" FromBaseType="TRUE" ShowInViewForms="FALSE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="URL"></Field>
  <Field ID="{9da97a8a-1da5-4a77-98d3-4bc10456e700}" Type="Note" Name="Comments" DisplayName="$Resources:core,Notes;" Sortable="FALSE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Comments"></Field>
  <Field ID="{DEDA572B-9D15-4FCE-81DA-D12EE9C29D61}" Type="Text" Name="Source" DisplayName="$Resources:X.CBAS.TargetedNav,FieldSource;" StaticName="Source" />
  <Field ID="{D68FEB34-BC7B-450D-8422-AA4CBA74D517}" Type="Text" Name="EpiwManagerYN" DisplayName="$Resources:X.CBAS.TargetedNav,FieldEpiwManagerYN;" StaticName="EpiwManagerYN" />
  <Field ID="{2a9ab6d3-268a-4c1c-9897-e5f018f87e64}" ReadOnly="TRUE" Filterable="FALSE" Type="Computed" Name="URLwMenu" DisplayName="$Resources:core,URL;" DisplayNameSrcField="URL" ClassInfo="Menu" AuthoringInfo="$Resources:core,URLwEditMenu;" ListItemMenuAllowed="Required" LinkToItemAllowed="Prohibited" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="URLwMenu">
    <FieldRefs>
      <FieldRef Name="URL" />
      <FieldRef Name="FileLeafRef" />
      <FieldRef Name="FileRef" />
      <FieldRef Name="FSObjType" />
      <FieldRef Name="_EditMenuTableStart2" />
      <FieldRef Name="_EditMenuTableEnd" />
    </FieldRefs>
  </Field>
  <Field ID="{7A7F3660-D408-4734-9AA0-2D86E33D79AB}" ReadOnly="TRUE" Filterable="FALSE" Type="Computed" Name="URLwMenu2" DisplayName="$Resources:core,URL;" DisplayNameSrcField="URL" ClassInfo="Menu" AuthoringInfo="$Resources:core,URLwEditMenu; (old)" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="URLwMenu2">
    <FieldRefs>
      <FieldRef Name="URL" />
      <FieldRef Name="FileLeafRef" />
      <FieldRef Name="FileRef" />
      <FieldRef Name="FSObjType" />
      <FieldRef Name="_EditMenuTableStart" />
      <FieldRef Name="_EditMenuTableEnd" />
    </FieldRefs>
  </Field>
  <Field ID="{aeaf07ee-d2fb-448b-a7a3-cf7e062d6c2a}" DisplaceOnUpgrade="TRUE" ReadOnly="TRUE" Filterable="FALSE" Type="Computed" Name="URLNoMenu" DisplayName="$Resources:core,URL;" DisplayNameSrcField="URL" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="URLNoMenu">
    <FieldRefs>
      <FieldRef Name="URL" />
      <FieldRef Name="FileLeafRef" />
      <FieldRef Name="FileRef" />
      <FieldRef Name="FSObjType" />
    </FieldRefs>
  </Field>
</Fields>

下面的代码显示了我遇到错误的位置 - 再次,没有什么特别的:

SPQuery query = new SPQuery() { Query = this.filterQuery };

//Loop through the returned URL(s) and add them to the list
foreach (SPItem item in list.getItems(query)) { //<-- Error happens here, when getting the enumerator for the SPListItemsCollection
      returnValue.Add(this.getUrlFromItem(item));
}

最后,CAML:

<Where>
  <FieldRef Name="Source" /> 
  <Value Type="Text">http://dev01:80/Pages/default.aspx</Value> 
</Where>

任何关于这里可能发生的事情的想法都将非常感激!

I have a SharePoint 2010 Farm solution that deploys a list, and a web part that reads from that list. It actually does more than that, but I can't get past the "read the list" part.

I'm able to successfully query the list and get back the SPListItemCollection, but when I attempt to loop through the items I get this totally ambiguous error "Cannot complete this action. Please try again." Full stack trace below:

[COMException (0x80004005): Cannot complete this action.

Please try again.<nativehr>0x80004005</nativehr><nativestack></nativestack>]
   Microsoft.SharePoint.Library.SPRequestInternalClass.GetListItemDataWithCallback2(IListItemSqlClient pSqlClient, String bstrUrl, String bstrListName, String bstrViewName, String bstrViewXml, SAFEARRAYFLAGS fSafeArrayFlags, ISP2DSafeArrayWriter pSACallback, ISPDataCallback pPagingCallback, ISPDataCallback pPagingPrevCallback, ISPDataCallback pFilterLinkCallback, ISPDataCallback pSchemaCallback, ISPDataCallback pRowCountCallback, Boolean& pbMaximalView) +0
   Microsoft.SharePoint.Library.SPRequest.GetListItemDataWithCallback2(IListItemSqlClient pSqlClient, String bstrUrl, String bstrListName, String bstrViewName, String bstrViewXml, SAFEARRAYFLAGS fSafeArrayFlags, ISP2DSafeArrayWriter pSACallback, ISPDataCallback pPagingCallback, ISPDataCallback pPagingPrevCallback, ISPDataCallback pFilterLinkCallback, ISPDataCallback pSchemaCallback, ISPDataCallback pRowCountCallback, Boolean& pbMaximalView) +256

[SPException: Cannot complete this action.

Please try again.]
   Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx) +27257906
   Microsoft.SharePoint.Library.SPRequest.GetListItemDataWithCallback2(IListItemSqlClient pSqlClient, String bstrUrl, String bstrListName, String bstrViewName, String bstrViewXml, SAFEARRAYFLAGS fSafeArrayFlags, ISP2DSafeArrayWriter pSACallback, ISPDataCallback pPagingCallback, ISPDataCallback pPagingPrevCallback, ISPDataCallback pFilterLinkCallback, ISPDataCallback pSchemaCallback, ISPDataCallback pRowCountCallback, Boolean& pbMaximalView) +27639062
   Microsoft.SharePoint.SPListItemCollection.EnsureListItemsData() +4145
   Microsoft.SharePoint.SPListItemCollection.GetEnumerator() +146
   X.CBAS.TargetedNav.TargetedNav.TargetedNav.getUrlsForUser() +433
   X.CBAS.TargetedNav.TargetedNav.TargetedNav.CreateChildControls() +437
   System.Web.UI.Control.EnsureChildControls() +146
   X.CBAS.TargetedNav.TargetedNav.TargetedNav.OnLoad(EventArgs e) +140
   System.Web.UI.Control.LoadRecursive() +66
   System.Web.UI.Control.LoadRecursive() +191
   System.Web.UI.Control.LoadRecursive() +191
   System.Web.UI.Control.LoadRecursive() +191
   System.Web.UI.Control.LoadRecursive() +191
   System.Web.UI.Control.LoadRecursive() +191
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2428

I've looked at the list definition several times and it looks sound, as is the web part code from what I can see.

The list definition:

<ContentTypes>
  <ContentTypeRef ID="0x0105">
    <Folder TargetName="Link" />
  </ContentTypeRef>
  <ContentTypeRef ID="0x0120" />
</ContentTypes>
<Fields>
  <Field ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" ReadOnly="TRUE" Required="FALSE" Hidden="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Title"></Field>
  <Field ID="{82642ec8-ef9b-478f-acf9-31f7d45fbc31}" Name="LinkTitle" Hidden="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="LinkTitle"></Field>
  <Field ID="{bc91a437-52e7-49e1-8c4e-4698904b2b6d}" Name="LinkTitleNoMenu" Hidden="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="LinkTitleNoMenu"></Field>
  <Field ID="{081c6e4c-5c14-4f20-b23e-1a71ceb6a67c}" Name="DocIcon" DisplaceOnUpgrade="TRUE" DisplayName="$Resources:core,Type;" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="DocIcon"></Field>
  <Field ID="{503f1caa-358e-4918-9094-4a2cdc4bc034}" Name="Edit" DisplayName="$Resources:core,Edit;" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Edit"></Field>
  <Field ID="{c29e077d-f466-4d8e-8bbe-72b66c5f205c}" Type="URL" Name="URL" DisplayName="$Resources:core,URL;" Required="TRUE" FromBaseType="TRUE" ShowInViewForms="FALSE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="URL"></Field>
  <Field ID="{9da97a8a-1da5-4a77-98d3-4bc10456e700}" Type="Note" Name="Comments" DisplayName="$Resources:core,Notes;" Sortable="FALSE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Comments"></Field>
  <Field ID="{DEDA572B-9D15-4FCE-81DA-D12EE9C29D61}" Type="Text" Name="Source" DisplayName="$Resources:X.CBAS.TargetedNav,FieldSource;" StaticName="Source" />
  <Field ID="{D68FEB34-BC7B-450D-8422-AA4CBA74D517}" Type="Text" Name="EpiwManagerYN" DisplayName="$Resources:X.CBAS.TargetedNav,FieldEpiwManagerYN;" StaticName="EpiwManagerYN" />
  <Field ID="{2a9ab6d3-268a-4c1c-9897-e5f018f87e64}" ReadOnly="TRUE" Filterable="FALSE" Type="Computed" Name="URLwMenu" DisplayName="$Resources:core,URL;" DisplayNameSrcField="URL" ClassInfo="Menu" AuthoringInfo="$Resources:core,URLwEditMenu;" ListItemMenuAllowed="Required" LinkToItemAllowed="Prohibited" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="URLwMenu">
    <FieldRefs>
      <FieldRef Name="URL" />
      <FieldRef Name="FileLeafRef" />
      <FieldRef Name="FileRef" />
      <FieldRef Name="FSObjType" />
      <FieldRef Name="_EditMenuTableStart2" />
      <FieldRef Name="_EditMenuTableEnd" />
    </FieldRefs>
  </Field>
  <Field ID="{7A7F3660-D408-4734-9AA0-2D86E33D79AB}" ReadOnly="TRUE" Filterable="FALSE" Type="Computed" Name="URLwMenu2" DisplayName="$Resources:core,URL;" DisplayNameSrcField="URL" ClassInfo="Menu" AuthoringInfo="$Resources:core,URLwEditMenu; (old)" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="URLwMenu2">
    <FieldRefs>
      <FieldRef Name="URL" />
      <FieldRef Name="FileLeafRef" />
      <FieldRef Name="FileRef" />
      <FieldRef Name="FSObjType" />
      <FieldRef Name="_EditMenuTableStart" />
      <FieldRef Name="_EditMenuTableEnd" />
    </FieldRefs>
  </Field>
  <Field ID="{aeaf07ee-d2fb-448b-a7a3-cf7e062d6c2a}" DisplaceOnUpgrade="TRUE" ReadOnly="TRUE" Filterable="FALSE" Type="Computed" Name="URLNoMenu" DisplayName="$Resources:core,URL;" DisplayNameSrcField="URL" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="URLNoMenu">
    <FieldRefs>
      <FieldRef Name="URL" />
      <FieldRef Name="FileLeafRef" />
      <FieldRef Name="FileRef" />
      <FieldRef Name="FSObjType" />
    </FieldRefs>
  </Field>
</Fields>

The code below shows where I'm running into the error - again, nothing special:

SPQuery query = new SPQuery() { Query = this.filterQuery };

//Loop through the returned URL(s) and add them to the list
foreach (SPItem item in list.getItems(query)) { //<-- Error happens here, when getting the enumerator for the SPListItemsCollection
      returnValue.Add(this.getUrlFromItem(item));
}

And finally, the CAML:

<Where>
  <FieldRef Name="Source" /> 
  <Value Type="Text">http://dev01:80/Pages/default.aspx</Value> 
</Where>

Any ideas on what might be happening here would be HUGELY appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不即不离 2024-10-23 18:51:24

我发现了这个问题 - CAML 语法很差。

错误的 CAML:

<Where>
  <FieldRef Name="Source" /> 
  <Value Type="Text">http://dev01:80/Pages/default.aspx</Value> 
</Where>

正确的 caml:

<Where>
  <Eq>
    <FieldRef Name="Source" /> 
    <Value Type="Text">http://dev01:80/Pages/default.aspx</Value> 
  </Eq>
</Where>

奇怪的是,我从未见过错误的 CAML 语法会导致这样的错误。

I discovered the issue - poor CAML syntax.

The bad CAML:

<Where>
  <FieldRef Name="Source" /> 
  <Value Type="Text">http://dev01:80/Pages/default.aspx</Value> 
</Where>

The proper caml:

<Where>
  <Eq>
    <FieldRef Name="Source" /> 
    <Value Type="Text">http://dev01:80/Pages/default.aspx</Value> 
  </Eq>
</Where>

Strangely, I've never seen bad CAML syntax result in an error like this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文