作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试以编程方式将新的 ListItem 添加到我的 SharePoint 2010 网站中的现有列表中。
我创建了一个新的 webpart ,使用以下事件处理程序向其中添加了一个按钮
protected void Unnamed1_Click(object sender, EventArgs e)
{
using (SPSite currentSiteCollection = new SPSite(SPContext.Current.Site.ID))
{
using (SPWeb currentWebsite = currentSiteCollection.OpenWeb(SPContext.Current.Web.ID))
{
SPListItem myNewItem = currentWebsite.Lists["myList"].AddItem();
myNewItem["Title"] = "newItem1";
myNewItem.Update();
}
}
}
将我的 Web 部件添加到 Sharepoint 2010 站点的默认页面...不幸的是,当我单击按钮时出现此错误
Attempted to use an object that has ceased to exist. (Exception from HRESULT: 0x80030102 (STG_E_REVERTED))
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: Attempted to use an object that has ceased to exist. (Exception from HRESULT: 0x80030102 (STG_E_REVERTED))
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[COMException (0x80030102): Attempted to use an object that has ceased to exist. (Exception from HRESULT: 0x80030102 (STG_E_REVERTED))]
Microsoft.SharePoint.Library.SPRequestInternalClass.SetDisableAfterEvents(Boolean bNewDisableAfterEvents) +0
Microsoft.SharePoint.Library.SPRequest.SetDisableAfterEvents(Boolean bNewDisableAfterEvents) +124
[SPException: Attempted to use an object that has ceased to exist. (Exception from HRESULT: 0x80030102 (STG_E_REVERTED))]
Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx) +27677298
Microsoft.SharePoint.Library.SPRequest.SetDisableAfterEvents(Boolean bNewDisableAfterEvents) +207
Microsoft.SharePoint.SPListItem.AddOrUpdateItem(Boolean bAdd, Boolean bSystem, Boolean bPreserveItemVersion, Boolean bNoVersion, Boolean bMigration, Boolean bPublish, Boolean bCheckOut, Boolean bCheckin, Guid newGuidOnAdd, Int32& ulID, Object& objAttachmentNames, Object& objAttachmentContents, Boolean suppressAfterEvents, String filename) +26793884
Microsoft.SharePoint.SPListItem.UpdateInternal(Boolean bSystem, Boolean bPreserveItemVersion, Guid newGuidOnAdd, Boolean bMigration, Boolean bPublish, Boolean bNoVersion, Boolean bCheckOut, Boolean bCheckin, Boolean suppressAfterEvents, String filename) +26793214
Microsoft.SharePoint.SPListItem.Update() +161
SLBWOA.Web.UCNewChecklist.UCNewChecklistUserControl.Unnamed1_Click(Object sender, EventArgs e) +259
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +115
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +140
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +29
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2981
我尝试了论坛上和通过谷歌提供的几种解决方案,但没有成功。
最佳答案
当我的列表定义包含一个 <Field Type="Choice">
时,我遇到了这个问题。用<Default>
里面的元素。
更新:如果我有 <Field Type="Choice">
就会出现问题不允许空值,并且我在创建列表项时没有将此字段设置为有效值之一。
关于c# - 试图使用已不复存在的对象。 (来自 HRESULT : 0x80030102 (STG_E_REVERTED)) 的异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9178952/
我是一名优秀的程序员,十分优秀!