title: Cannot cancel deletion in List Item event receiver ItemDeleting method in CMSPUBLISHINGSITE#2
body: <p>Using the SharePoint 2010 RC I am having issues canceling the deletion of a list item using event receivers. My code is firing, setting the cancel property of the SPItemEventProperties, setting an error message, and throwing an error back to the calling thread. This approach works fine in the adding/updating methods, however, when used in the deleting method I can watch the code fire in a debugger, but the item is still moved to the site's recycling bin.</p>
  
  <p>Further, I am seeing this behavior in a site created from the "CMSPUBLISHINGSITE#2" template from stsadm, but not from a site created from the "Team Site" template via Central Administration.</p>
  
  <p>The misbehaving code follows:</p>
  
  <pre><code>public override void ItemDeleting(SPItemEventProperties properties)
  {
      if (!(properties.UserLoginName == "SHAREPOINT\\system"))
      {
          try
          {
              throw new CreatorIdAliasingException("Please contact support if you feel a release web site has been inappropriately assigned to your organization.");
          }
          catch (CreatorIdAliasingException ex)
          {
              properties.Cancel = true;
              properties.ErrorMessage = ex.ToString();
              properties.InvalidateListItem();
              throw;
          }
      }
  }
  </code></pre>
  
  <p>For reference, identical code is contained in the ItemAdding method and works as expected.</p>
  
  <pre><code>public override void ItemAdding(SPItemEventProperties properties)
          {
              base.ItemAdding(properties);
              if (!(properties.UserLoginName == "SHAREPOINT\\system"))
              {
                  try
                  {
                      throw new InvalidCreatorIdException("Please contact support to add a known URL to your list of release web sites.");
                  }
                  catch (InvalidCreatorIdException ex)
                  {
                      properties.Cancel = true;
                      properties.ErrorMessage = ex.ToString();
                      properties.InvalidateListItem();
                      throw;
                  }
              }
          }
  </code></pre>