Attempted to use an object that has ceased to exist. (Exception from HRESULT: 0x80030102 (STG_E_REVERTED))

3

Well I'm trying to programmatically add a new ListItem to an already existing List in my SharePoint 2010 website.

I've created a new webpart , added a single button to it with the following event handler

    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();
            }
        }

    }

Added my webpart to the default page of the sharepoint 2010 site ... by unfortunately when I click the button I get this error

    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

I've tried several solutions available on the forum and through google but with no luck.

c#
visual-studio
visual-studio-2010
sharepoint
sharepoint-2010
asked on Stack Overflow Feb 7, 2012 by MikaEG • edited Feb 7, 2012 by John Saunders

3 Answers

1

I ran into this problem when my list definition contained, of all things, a <Field Type="Choice"> with a <Default> element inside.

Update: The problem occurs if I have a <Field Type="Choice"> that doesn't allow an empty value, and I don't set this field to one of the valid values when creating the list item.

answered on Stack Overflow Mar 19, 2012 by Tor Hovland • edited Mar 19, 2012 by Tor Hovland
0

I had this error on every list view in one of sub-sites in SharePoint 2010, on default views also. It turned out that a user changed a time zone in site's regional settings to another time zone (+8), after I changed it back all started to work again )

answered on Stack Overflow Apr 2, 2015 by Alexey Semenko
0

Did you try :

    protected void Unnamed1_Click(object sender, EventArgs e)
{
    SPSite currentSiteCollection = SPContext.Current.Site;
    using (SPWeb currentWebsite = currentSiteCollection.OpenWeb(SPContext.Current.Web.ID))
    {
        SPListItem myNewItem = currentWebsite.Lists["myList"].AddItem();
        myNewItem["Title"] = "newItem1";
        myNewItem.Update();
    }
}
answered on Stack Overflow Apr 5, 2017 by SP_LudoPerr

User contributions licensed under CC BY-SA 3.0