I keep getting this error:
Item does not exist. It may have been deleted by another user.
I dont know if theres something wrong with my assembly, but its breaking here:
Line 227:
Line 228:
Line 229: SPListItem item = list.GetItemById(Int32.Parse(projectApprovalId));
Line 230: SPFolder itemFolder = item.Folder;
Line 231:
I think its something to do with my assembly, like it may not be importing sharepoint correctly.
I am using a .ashx file in my layouts folder, it is an ihttphandler. Here is what my file looks like:
<%@ 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;
.........
Here is the stack trace:
[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 Ser开发者_Go百科ver 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
Code where its breaking:
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;
What is projectApprovalId
? The error is being caused because there is no item in that list that has an ID
of what ever the value of projectApprovalId
is.
精彩评论