Description

SPContext objects are managed by the SharePoint framework and should not be explicitly disposed in your code.

Inappropriate usage:


using (var site = SPContext.Current.Site)
{
}


Resolution

You need to ensure that you only dispose SPSite and SPWeb objects that your code owns.


using (var site = new SPSite(SPContext.Current.Site.ID))
{
}


This method will ensure that a new independent SPSite object is created which you then can dispose without side effects on other code using the SPSite object bound to the current SPContext object.

Links