If you are getting the error in a different case i.e.when your custom code is where the error is thrown (in the case described here the error is thrown in the Share Point code) you could implement a workaround of waiting and retrying your action again and again after a few seconds for a couple times. Add Or Update Item(String bstr Url, String bstr List Name, Boolean b Add, Boolean b System Update, Boolean b Preserve Item Version, Boolean b Update No Version, Int32& pl ID, String& pbstr Guid, Guid pbstr New Doc Id, Boolean b Has New Doc Id, String bstr Version, Object& pvar Attachment Names, Object& pvar Attachment Contents, Object& pvar Properties, Boolean b Check Out, Boolean b Checkin, Boolean b Migration, Boolean b Publish String bstr Url, String bstr List Name, Boolean b Add, Boolean b System Update, Boolean b Preserve Item Version, Boolean b Update No Version, Int32& pl ID, String& pbstr Guid, Guid pbstr New Doc Id, Boolean b Has New Doc Id, String bstr Version, Object& pvar Attachment Names, Object& pvar Attachment Contents, Object& pvar Properties, Boolean b Check Out, Boolean b Checkin, Boolean b Migration, Boolean b Publish String bstr Url, String bstr List Name, Boolean b Add, Boolean b System Update, Boolean b Preserve Item Version, Boolean b Update No Version, Int32& pl ID, String& pbstr Guid, Guid pbstr New Doc Id, Boolean b Has New Doc Id, String bstr Version, Object& pvar Attachment Names, Object& pvar Attachment Contents, Object& pvar Properties, Boolean b Check Out, Boolean b Checkin, Boolean b Migration, Boolean b Publish Boolean b Add, Boolean b System, Boolean b Preserve Item Version, Boolean b No Version, Boolean b Migration, Boolean b Publish, Boolean b Check Out, Boolean b Checkin, Guid new Guid On Add, Int32& ul ID, Object& obj Attachment Names, Object& obj Attachment Contents, Boolean suppress After Events) 3215 I spent some time writing test code to try and reproduce the problem when multiple threads are doing updates to the same file and I finally managed to get the error.

eventhandler itemupdating-87

Below Power Shell attaches the event handler to a document library.

I have initialized a sequence number and increment this number every time we attach an event handler.

Also, in case you are planning to remove any event receivers, ensure that you take a backup of the list of event receivers.

Because, if we don’t and we remove the event receivers in a loop, we do not have the information to add them back. Web Url; Write-Host($web Url); ## open the web site Write-Host "Opening web $web Url" -nonewline $web = Get-SPWeb $web Url Write-Host "$web" Write-host " – done " -foreground green foreach($handler in $site.

Well we cannot change the Share Point code so we have to find a way to update our event receiver code (which is the one with index “1” above).

Also note that the Edit uses exactly the SPList Item.

This is because if we were to add code to remove the existing event handers, we can insert the following command: Within the loop, we cannot add or remove items from the collection if we are looping the index in the ascending order i.e start with 0 till the end of the loop (we get an error that the collection was modified if we do that).

In this case, since we are just listing the event receivers we can even use ascending loop.

In this article I want to share how to use Power Shell to attach event receiver to a list, provide configuration values from an xml.