SPC110232: Do not dispose SPWebEventProperties.Web

The SPWeb object in SPWebEventProperties (e.g. used in a SPWebEventReceiver) should not be disposed.

TypeName: DoNotDisposeSPWebEventPropertiesWeb
CheckId: SPC110232
Severity: CriticalWarning
Type: AssemblyFileReference

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

Bad Coding Practice

public class WebEventReceiver : SPWebEventReceiver
  public override void WebAdding(SPWebEventProperties properties)
    SPWeb web = properties.Web;
    // ..
    web.Dispose(); // DO NOT DO THIS.


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


comments powered by Disqus