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

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


When working with visual webpart control, my visual webpart works fine, but when i deploy the more then one Visual webpart on a single page, it gives me above error, while going in to many forums and reading the blogs, i was wondering there is some thing with my code and the SPSite and SPWeb object disposal.

i used to write the code like this

using (SPSite site =SPContext.Current.Site)
{

using (SPWeb web = site.RootWeb)
{

// your code

}

}

though i am scoping the object rightly(using automatically dispose the object the routine gets outside the scope), but there is still some thing missing, after some time i figured out that the problem is with SPContext object rather than SPsite object, because once it dispose in one Visual Webpart, it can not be acquired back, so i change the code like this

using (SPSite site = new SPSite(SPContext.Current.Site.Url))
{

using (SPWeb web = site.RootWeb)
{

// your code

}

}

and do use the using scope, it will save you from explicitly disposing the objects 😀

using (SPSite site = new SPSite(SPContext.Current.Site.Url))

using (SPWeb web = site.RootWeb)
{

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

  1. Hi,

    I am geting this error. Tried above method for dispose, but did’nt work out. Can you please look into this.

    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 File: c:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\root\5bb91b38\bcc3e778\App_Web_rootwelcome.aspx_606526083.jfewljhu.0.cs Line: 0

      1. Shakir i got solved.Actaully it was due to my site dataquerys object was instantiated out of scope.
        But i had one more doubt.How can we able to bind our rating control to one of my web part contains grid which need to show all my rated inforamtion of pages and also user should able to rate same back for particular page.

      2. sound great!
        is rating your own control( Ajax control etc) or you want to use SharePoint’s one.
        regards,

      3. Right now i was using sharepoints Average rating control.I struck up here:I have an Custom WebPart which displays a Content from the sharepoint list.To this same webpart i need a Rating control for the User, this control should effect the Rating(0-5) column in the list for the specified content.

      4. You can use the Ajax control, map the values from the list for the rating and show their in then control, or you can use SharePoint’s control in your custom webpart

      5. At the same time i need to update the value if i assign new rating to that the page from grid where i was displaying all page URL which got rated along with rating control where it will be displaying earlier rated information for that particular page.

  2. Could you help me…

    void Page_Load(object sender, System.EventArgs e)
    {
    //SPWeb web = SPContext.Current.Web;

    try
    {

    CDOC.SharePoint.OrganizationalTree.UserProfile userProfile = CDOC.SharePoint.OrganizationalTree.Organization.GetProfile(ref web);

    if (!userProfile.Verify(CDOC.SharePoint.OrganizationalTree.ProfileType.UsuarioArea) && !userProfile.IsAdministrator)
    {
    Response.Redirect(“~/default.aspx”);
    }
    }
    catch { }
    }

    <SharePoint:EncodedLiteral runat="server" text="” EncodeMethod=”HtmlEncode”/>

    TD.ms-titleareaframe, .ms-pagetitleareaframe {
    height: 10px;
    }
    Div.ms-titleareaframe {
    height: 100%;
    }
    .ms-pagetitleareaframe table {
    background: none;
    height: 10px;
    }

    var navBarHelpOverrideKey = “wssmain”;

    .ms-bodyareaframe {
    padding: 0px;
    }

     

  3. Excellent – that did the trick! Re-read about when to use using and I shouldn’t have been auto disposing the context – horrible error message

  4. Hi Shakir!

    You are my hero of the day. There were other sites which had a solution to this problem but none of them worked for me. You explained everything very well.

    Kudos,

    Mario

  5. I need help with the error below
    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.GetWebListPermMask(String bstrUrl, String bstrListName) +0
    Microsoft.SharePoint.Library.SPRequest.GetWebListPermMask(String bstrUrl, String bstrListName) +134

    [SPException: Attempted to use an object that has ceased to exist. (Exception from HRESULT: 0x80030102 (STG_E_REVERTED))]
    Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx) +27615618
    Microsoft.SharePoint.Library.SPRequest.GetWebListPermMask(String bstrUrl, String bstrListName) +225
    Microsoft.SharePoint.SPList.get_EffectiveBasePermissions() +102
    Microsoft.SharePoint.WebPartPages.WikiEditPage.OnPreRender(EventArgs e) +754
    System.Web.UI.Control.PreRenderRecursiveInternal() +108
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3394

    *************************************Here is the code********************
    using System;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Microsoft.SharePoint;

    namespace wpSiteList.wpSiteListV1
    {
    public partial class wpSiteListV1UserControl : UserControl
    {
    protected void Page_Load(object sender, EventArgs e)
    {
    try
    {
    SPSite mySite = SPContext.Current.Web.Site;
    using (SPSite oSite = mySite)
    {
    using (SPWeb oWeb = oSite.OpenWeb())
    {
    foreach (SPList oList in oWeb.Lists)
    {
    //Console.WriteLine(“Title: {0} Created: {1}”, oList.Title, oList.Created.ToString());
    lblMsg.Text += oList.Title.ToString() + “\n”;
    }

    }
    }
    }
    catch (Exception ex)
    {
    Response.Write(ex.Message);
    }
    }
    }
    }

    1. Dear,

      Sorry for late reply, please replace the following code
      SPSite mySite = SPContext.Current.Web.Site;
      using (SPSite oSite = mySite)

      with below one

      string siteURL = SPContext.Current.Web.Url;
      using (SPSite oSite = new SPSite(siteURL)
      As it can be observed that i am OSite object from URL not from the Current context object.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s