1

Getting below exception when adding a webpart to page on Production. On Development server it works perfectly fine.

Have been googling a lot but not able to get links for specifically this scenario.

System.Runtime.InteropServices.COMException: Attempted to use an object that has ceased to exist. (Exception from HRESULT: 0x80030102 (STG_E_REVERTED))
at Microsoft.SharePoint.Library.SPRequestInternalClass.GetListsWithCallback(String bstrUrl, Guid foreignWebId, String bstrListInternalName, Int32 dwBaseType, Int32 dwBaseTypeAlt, Int32 dwServerTemplate, UInt32 dwGetListFlags, UInt32 dwListFilterFlags, Boolean bPrefetchMetaData, Boolean bSecurityTrimmed, Boolean bGetSecurityData, Boolean bPrefetchRelatedFields, ISP2DSafeArrayWriter p2DWriter, Int32& plRecycleBinCount)
at Microsoft.SharePoint.Library.SPRequest.GetListsWithCallback(String bstrUrl, Guid foreignWebId, String bstrListInternalName, Int32 dwBaseType, Int32 dwBaseTypeAlt, Int32 dwServerTemplate, UInt32 dwGetListFlags, UInt32 dwListFilterFlags, Boolean bPrefetchMetaData, Boolean bSecurityTrimmed, Boolean bGetSecurityData, Boolean bPrefetchRelatedFields, ISP2DSafeArrayWriter p2DWriter, Int32& plRecycleBinCount)

Am I missing some thing? Because this WSP has 6 web parts they all work fine except this.

1
0

Ho, long time no see!
This used to be a very common mistake, and the difficulty with it is:

  • it occurs randomly
  • most of the time under heavy user pressure only (hence the "it works fine on dev server")
  • the error is most probably not within the Web part incriminated by the error message!

The mistake relays in the code you wrote: in one of the Web parts instanciated before the one raising the error, someone closes the contextual (i.e. shared) SPWeb (or SPSite) object. e.g.:

// BAD
SPWeb myWeb = SPContext.Current.Web;
...
myWeb.Dispose();

or:

// BAD
using(SPWeb myWeb = SPContext.Current.Web)
{
   ...
}

Contextual SP objects (i.e. SPWeband SPSite from SPContext, or in another word, any SP object you did not open yourself explicitely) must not be closed by you!
If you close these (shared) objects, other components on the page (like other Web parts) will try to use them while they've been closed in the meantime!
The problem is random because:

  1. It depends on the order of execution of the page components (e.g. the order of Web parts on the page)
  2. Actual disposing of objects may be deferred depending on the memory pressure.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.