SPC110234: Do not dispose SPItemEventProperties.ListItem.Web

The object in SPItemEventProperties.ListItem.Web (e.g. used in a SPItemEventReceiver) should not be disposed.

TypeName: DoNotDisposeSPItemEventPropertiesListItemWeb
CheckId: SPC110234
Severity: CriticalWarning
Type: AssemblyFileReference

Do not call Dispose on SPItemEventProperties.ListItem.Web. See sample:

Bad Coding Practice

public class ItemEventReceiver : SPItemEventReceiver
  public override void ItemAdded(SPItemEventProperties properties)
     SPWeb web = properties.ListItem.Web;
     web.Dispose(); // DO NOT DO THIS.


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


comments powered by Disqus