Solving: Attempted to use an object that has ceased to exist.


Save Time With Sharegate
Migration, Security, Reporting. SharePoint & Office 365. Try Free!
Sharegate: Kick-Ass Tool
Think Your SharePoint & Office 365 Are Secure ? Find Out Now!
SharePoint Office 365 Tool
Simple & Powerful Tool for Migration, Security & Reporting. Free Trial

Sometimes in SharePoint you get errors that were not very clear when you start. However if you develop for some time in SharePoint you’ll learn the best practices and you will avoid some simple mistakes. One of these errors is:¬†Attempted to use an object that has ceased to exist. (Exception from HRESULT: 0x80030102 (STG_E_REVERTED))

The error message “Attempted to use an object that has ceased to exist. (Exception from HRESULT: 0x80030102 (STG_E_REVERTED))” occurs when you dispose the SPWeb object in SharePoint. When once disposed it is never accessible anymore.

You should look in your code for

(SPWeb site = SPContext.Current.Site) {…}

The solution is to replace this by

using (SPWeb elevatedSite = elevatedsiteColl.OpenWeb(siteID)) { … }

Guid siteID = SPContext.Current.Web.ID;

For further reading about best practices disposing SharePoint services object, read this post on MSDN

Leave a comment

Your email address will not be published. Required fields are marked *