物品不存在。它可能已被其他用户删除

时间:2011-07-12 23:53:27

标签: c# asp.net sharepoint

我一直收到这个错误:

Item does not exist. It may have been deleted by another user.

我不知道我的装配是否有问题,但它在这里打破了:

Line 227:
Line 228:
Line 229:                    SPListItem item = list.GetItemById(Int32.Parse(projectApprovalId));
Line 230:                    SPFolder itemFolder = item.Folder;
Line 231:                   

我认为它与我的程序集有关,就像它可能无法正确导入sharepoint一样。

我在layouts文件夹中使用.ashx文件,它是一个ihttphandler。这是我的文件的样子:

   <%@ Assembly Name="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ WebHandler Language="C#" Class="jQueryUploadTest.Upload" %>

    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Security.AccessControl;
    using System.Web;
    using System.Web.Script.Serialization;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using Microsoft.SharePoint;
    //using Microsoft.Office.DocumentManagement.DocumentSets;

    namespace jQueryUploadTest {



public class Upload : IHttpHandler {
        public class FilesStatus
        {/*
            public string thumbnail_url { get; set; }
            public string name { get; set; }
            public string url { get; set; }
            public int size { get; set; }
            public string type { get; set; }
            public string delete_url { get; set; }
            public string delete_type { get; set; }
            public string error { get; set; }
            public string progress { get; set; }
           */

            private string m_thumbnail_url;
            private string m_name;
            private string m_url;
            private int m_size;
            private string m_type;
            private string m_delete_url;
    .........

这是堆栈跟踪:

[ArgumentException: Item does not exist. It may have been deleted by another user.]
   Microsoft.SharePoint.SPList.GetItemById(String strId, Int32 id, String strRootFolder, Boolean cacheRowsetAndId, String strViewFields, Boolean bDatesInUtc) +26965608
   Microsoft.SharePoint.SPList.GetItemById(Int32 id) +116
   jQueryUploadTest.Upload.ListCurrentFiles(HttpContext context) in c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\IrvineCompany.SharePoint.CLM\aspx\Upload.ashx:229
   jQueryUploadTest.Upload.ServeFile(HttpContext context) in c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\IrvineCompany.SharePoint.CLM\aspx\Upload.ashx:200
   jQueryUploadTest.Upload.HandleMethod(HttpContext context) in c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\IrvineCompany.SharePoint.CLM\aspx\Upload.ashx:70
   jQueryUploadTest.Upload.ProcessRequest(HttpContext context) in c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\IrvineCompany.SharePoint.CLM\aspx\Upload.ashx:63
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +599
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +171

破解的代码:

private void ListCurrentFiles (HttpContext context) {
            List<FilesStatus> files = new List<FilesStatus>();
            SPFileCollection fileCollection;
            //using(SPSite siteCollection = new SPSite()){
            using (SPWeb site = SPContext.Current.Web)
                {
                    string projectApprovalId = string.Empty;
                    if (System.Web.HttpContext.Current.Request.QueryString["ProjectApprovalId"] != null)
                    {
                        projectApprovalId = System.Web.HttpContext.Current.Request.QueryString["ProjectApprovalId"].ToString();
                    }
                    SPList list = site.Lists.TryGetList(GetResourcePropertyValue("KEY_CLM_DocumentLibrary_Name"));


                    SPListItem item = list.GetItemById(Int32.Parse(projectApprovalId));
                    SPFolder itemFolder = item.Folder;


                    fileCollection = itemFolder.Files;

1 个答案:

答案 0 :(得分:0)

什么是projectApprovalId?导致错误是因为该列表中没有任何项ID具有projectApprovalId的值{。}}。