SPC110241: Do not dispose SPSite.RootWeb

An earlier version of the documentation indicated that the calling application should dispose of the SPSite.RootWeb property just before disposing of the SPSite object that is using it. This is no longer the official guidance. The dispose cleanup is handled automatically by the SharePoint framework.

TypeName: DoNotDisposeSPSiteRootWeb
CheckId: SPC110241
Severity: CriticalWarning
Type: AssemblyFileReference
Resolution

Do not call Dispose on SPSite.RootWeb. MSDN: An earlier version indicated that the calling application should dispose of the SPSite.RootWeb property just before disposing of the SPSite object that is using it. This is no longer the official guidance. The dispose cleanup is handled automatically by the SharePoint framework. Additionally, SPSite properties LockIssue, Owner, and SecondaryContact used the RootWeb property internally. Given the updated guidance for RootWeb, it is no longer advisable to call the Dispose method on the SPSite.RootWeb property whenever any of these properties are used.

Remarks

Rule relates to SPDisposeCheckId 'SPDisposeCheckID_655'. To ignore this rule add the attribute '[SPDisposeCheckIgnore(SPDisposeCheckID.SPDisposeCheckID_655, "Caller will dispose")]' to your method.

Links

comments powered by Disqus