Hello there,
I have read several articles that recommended not to dispose the SPWeb object received from calling SPWeb.ParentWeb. Most of these articles either reference the technet-article at https://msdn.microsoft.com/en-us/library/aa973248%28v=office.12%29.aspx or quoted the update from that article:
"An earlier version of this article recommended that the calling application should dispose of the SPWeb.ParentWeb. This is no longer the official guidance. The dispose cleanup is handled automatically by the SharePoint framework."
But the technet article only covers WSS3.0 and if I reflect the ParentWeb property of SPWeb using ILSpy I find this line ("this" below refers to the SPWeb and this.m_ParentWeb is the returned variable):
this.m_ParentWeb = this.Site.OpenWeb(parentWebUrl);
The call to OpenWeb(parentWebUrl) makes be think that you should dispose of the ParentWeb and it is also consistent with our tracelog entries which report the "Potentially excessive number of SPRequest objects (x) currently unreleased on thread y" warning message immediately after calling SPWeb.ParentWeb multiple times.
So should I dispose it or not? Is the tracelog-error a false positive?
- Edited by boomshanka Wednesday, July 29, 2015 1:28 PM Minor corrections