This is known error to sharepoint developers that when try to update/delete a SharePoint list item using system account. Means using SPSecurity.RunWithElevatedPrivileges() method. I am not sure, why it is not allowing to update or delete a file in this code block. But, there is work around for it. You can still edit the item using elevated privileges. Here is a wonderful post, which helped me great and all credits to him.
Make changes to SPListItem using elevated privileges
I am really surprised by seeing the code in his article. It is completely unexpected and it is working great. I am really not believed when I saw the code very first time, but it is working.
But, make sure you are disposing the objects correct. Hope this will help you too to fix the problem "Operation is not valid due to the current state of the object".
No comments:
Post a Comment