I have a library, that has versioning enabled.

On that library is an event receiver that does stuff, on ItemUpdated.

Ok, if the user uploads a document, and does not rename the document during the upload, everything works fine.


If the user uploads a document and renames it during the upload, the event receiver fails.

The code that fails is as follows:

SPListItem eItem = this._rootWeb.Lists["Listname"].GetItemByUniqueId(item.UniqueId);

Where this._rootWeb is a web in elevated permissions, and item is the listitem that is received by the event receiver.

The error received is:

Value does not fall within expected range.

Any ideas how to do this so that it will be able to find the item even if the user renamed it?

Basically I am trying to get the item the user added, in elevated privileges.

  • instead of itemUpdated, can you try while item.updating event? this is synchronous event.
    – Nik
    Jul 23, 2014 at 21:13

1 Answer 1


Try checking the item.AfterProperties or the item.AfterUrl. It's weird that you can't get the item by using its UniqueId, but you have to check other things as well.

Is item in your case properties.ListItem, where properties is of type SPItemEventProperties? If not, that could also be the culprit as you should work with the item passed into your event receiver as property.

  • Hi :) Thanks for responding, the item is the splistitem, and yes it is the listitem from properties.ListItem... so all in all I have no idea why I would not be able to find it using its UniqueID. Apr 11, 2013 at 15:20
  • As I said, check the before and after properties. Maybe the rename action does something weird. Also Renaming the list item might trigger the same event receiver twice, you have to check that too.
    – Dennis G
    Apr 11, 2013 at 21:24
  • 1
    Adding in a delay before looking for the item has solved this. Something is clearly happening in parallel that needs to complete before you can access the item Apr 15, 2013 at 7:18
  • Could be, did you try specifying the Synchronization property to synchronous? msdn.microsoft.com/en-us/library/…
    – Dennis G
    Apr 15, 2013 at 7:38

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.