SPC110231: Do not dispose SPListEventProperties.Web

The SPWeb object in SPListEventProperties (e.g. used in a SPListEventReceiver) should not be disposed.

TypeName: DoNotDisposeSPListEventPropertiesWeb
CheckId: SPC110231
Severity: CriticalWarning
Type: AssemblyFileReference

Do not call Dispose on SPListEventProperties.Web. See sample:

Bad Coding Practice

public class ListEventReceiver : SPListEventReceiver
  public override void FieldAdded(SPListEventProperties properties)
    properties.Web.Dispose(); // DO NOT DO THIS.


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


comments powered by Disqus