How to fix “Collection was modified; enumeration operation may not execute. “when using Copy.asmx in SharePoint2010

Posted by ybbest on YBBest See other posts from YBBest or by ybbest
Published on Sat, 21 Apr 2012 09:06:49 +0000 Indexed on 2012/05/30 17:03 UTC
Read the original article Hit count: 812

Problem:

In my current project, we use copy.asmx web services in SharePoint2010 to upload a document to a document library. In one of the document library, when uploading a document with a choice field, it blows up and the error message is Collection was modified; enumeration operation may not execute.

Analysis:

After some research , we found out the problem is that we have 2 content types that both have a field called Document Type , although the internal name are different but the display name are exactly the same and this cause the problem. I am still not too sure why, it could possibly a SharePoint bug.

Solution:

After rename one of the field display name to a different name, it works like a charm. You can download source code with the problem here and source code without the problem here.


© YBBest or respective owner

Related posts about Web Services

Related posts about Problem Solving