I got many warnings from the SPDispose checker like this:
ID: SPDisposeCheckID_140 Module: xx.xx.dll Method: xx.xx.Layouts.xx.UpdateWorkspace.Page_Load(System.Object,System.EventArgs) Statement: RootWeb := RootSite.{Microsoft.SharePoint.SPSite}get_RootWeb() Source: UpdateWorkspace.aspx.cs Line: 201 Notes: Disposable type not disposed: Microsoft.SharePoint.SPWeb ***This may be a false positive depending on how the type was created or if it is disposed outside the current scope
More Information: http://blogs.msdn.com/rogerla/archive/2008/02/12/sharepoint-2007-and-wss-3-0-dispose-patterns-by-example.aspx#SPDisposeCheckID_140
My code is as follows, For me its OK, its a false positive, but I wanted to know if somebody might see any issue here
protected void Page_Load(object sender, EventArgs e) {
//Go to home site and retrieve values
SPWeb ThisWeb = SPContext.Current.Site.RootWeb;
currentsiteurl = ThisWeb.Url;
SPWebApplication ThisWebApplication = SPWebApplication.Lookup(new Uri(currentsiteurl));
WebAppUrl = ThisWebApplication.GetResponseUri(SPUrlZone.Default).AbsoluteUri;
using (SPSite RootSite = new SPSite(WebAppUrl))
{
SPWeb RootWeb = RootSite.RootWeb;
}
if (!IsPostBack)
{
SPWeb Currentweb = SPContext.Current.Web;
SiteTitle.Text = Currentweb.Title;
SiteDescription.Text = Currentweb.Description;
SupportEmail.Text = Currentweb.Properties["x-SupportEmail"];
ContactEmail.Text = Currentweb.Properties["x-ContactEmail"];
currentsiteurl = Currentweb.Url;
ListID = Convert.ToInt32(Currentweb.Properties["SiteListID"]);
SPWebApplication MyWebApplication = SPWebApplication.Lookup(new Uri(currentsiteurl));
WebAppUrl = MyWebApplication.GetResponseUri(SPUrlZone.Default).AbsoluteUri;
IntAppUrl = MyWebApplication.GetResponseUri(SPUrlZone.Internet).AbsoluteUri;
webapp = currentsiteurl.Replace(IntAppUrl, WebAppUrl);
currentsiteurl = (currentsiteurl.Substring(currentsiteurl.LastIndexOf('/'))).Trim('/');
#region Read values from central site settings list
using (SPSite RootSite = new SPSite(WebAppUrl))
{
SPWeb RootWeb = RootSite.RootWeb;
Debug.Text += "<br>RootWebUrl second loop: " + RootWeb.Url;
string listUrl = string.Format("{0}/Lists/x", RootWeb.Url);
SPList list = RootWeb.GetList(listUrl);
SPListItem item = list.GetItemById(ListID);
}
#endregion
}
}
