jaku
jaku

Reputation: 81

Why is the event getting fired twice when using an Event Receiver project from Visual Studio 2010?

I am able to fire an Event using an Event receiver which I created using Visual Studio 2010 on a custom list. But instead of firing once, it fires twice. I tried to debug the code and I saw that the ItemAdded event was getting executed twice. Is there any particular reason that this is executing in such a manner?

Upvotes: 1

Views: 7759

Answers (2)

jaku
jaku

Reputation: 81

Alas!! I found it!!! I had left the elements file for the Event Receiver there, and therefore when the feature was activated for the project, the receiver got associated to ALL custom lists on the site. And in the Feature Activated event, I was stapling the event to the particular custom list. So, in effect, the Event receiver was getting attached to my particular custom list twice, ie, from the elements file & feature activated event. So, i just deleted the elements file of the event reveicer and it WORKED!!!

Thanks all for your suggestions...

Upvotes: 3

Francois Verbeeck
Francois Verbeeck

Reputation: 978

You should check if your itemAdded event handler has not been registered twice. If yes, then deactivate the feature and delete the duplicate receiver.

You can use SharePoint Manager 2010 from codeplex to figure out how many event handlers are attached to your list

It might also be related to your versioning / requirement of checking out the file within the library : http://support.microsoft.com/kb/939307 this was for 2007 but still the case in 2010

Regards

Upvotes: 1

Related Questions