I am working on a share-point 2010 custom list event receiver(item adding, item updating,item added), once in a while i will notice that when i create a new item, it seems like the event receiver wont fire but then in the list there will be entries for the created By column and the Created Column...how can i make the event receiver to fire all the time, or else if not is there a way to throw an error on the page when the event receiver is not fried, so that the user will know that the ticket is not being generated(and then prevent the columns(createdBy and the Created columns) to be added to the list when the event is not fired

  • What do you mean "entries for the created by column and the created column"? You end up with an empty item with only those column filled up?
    – Louis
    Feb 3, 2012 at 23:50
  • yes Louis, i end up with an empty item with only those column filled up
    – SandeshR
    Feb 4, 2012 at 0:35
  • Where are you normally getting the missing values? In your add/edit form or in the event receiver? It looks like your event receiver is exiting half way through.
    – Louis
    Feb 4, 2012 at 1:32

1 Answer 1


There is no way to act when an event is not triggered. That would sort of go against the logic of event handlers.

As per your other thread, you might have a code error in your event receiver, causing it to throw an exception and exit unfinished.

You might also have concurrency issues. Are you disabling event triggers while you are executing them (SPEventReceiverBase.EventFiringEnabled)? That will prevent events from being handled until you set Firing back to true. It will prevent any events (in the current thread) in any list until you set it back (see How DisableEventFiring / EventFiringEnabled works).

Best practice #1: If you disable event firing in your event handler, use a try-catch-finally block and re-enable them in your finally part. You might be leaving them disabling if you exit on an exception.

Best practice #2: Event handlers should be very short, especially the parts where you are disabling event firing. Especially asynchronous events.

Best practice #3: For nicer event cohabitation, implement your own event-type-specific event firing-disabling boolean (e.g. put a static bool in your event's class, and at the start of your event check if it's true or false before proceeding)

Best practice #4: You should not instantiate SPWeb or SPSite objects inside event handlers (other than SPItemEventProperties.Web) (ref)

  • +1 very thorough answer, thanks! (actually I was writing a similar one at the moment :)...). Btw, properly speaking, EventFiringEnabled doesn't obligatory prevent all the lists from firing their event receivers. It is ThreadStatic, hence it will sometimes fire, and sometimes it won't. Feb 4, 2012 at 0:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.