Answered Collection was modified; enumeration operation may not execute

  • Saturday, April 28, 2012 3:51 PM
     
     

    Hello all,

    I have created a workflow in visual studio 2010. I then created a "CreateTask" activity without any problem, but when i try to update any task item in "UpdateTask" activity it gives the following error on the last line of code.

    Collection was modified; enumeration operation may not execute.

    Following is the code which is written on "UpateTask" actvity in visual stduio. If anyone have solution for this then please help. Thanks in advance.


    private void updateTask1_MethodInvoking(System.Object sender, System.EventArgs e)

    {

          if (this.workflowProperties.Item("WFStatus").ToString == "Reassign") {

                int itemId = this.createTask1_TaskProperties1.TaskItemId;

                updateTask1_TaskProperties1.TaskItemId = itemId;

                updateTask1_TaskProperties1.AssignedTo = "DOMAIN\\mareena.arrora";

                updateTask1.TaskProperties = updateTask1_TaskProperties1;

          }

    }




    • Edited by Marreena Saturday, April 28, 2012 3:52 PM
    • Edited by Marreena Saturday, April 28, 2012 3:52 PM
    • Edited by Marreena Sunday, April 29, 2012 3:00 PM
    •  

All Replies

  • Sunday, April 29, 2012 6:42 PM
     
     Answered

    Hi,

    You dont have to explicitly set the Task Item Id.Here is a link that can give you a clear insight of how to use the update activity.

    Hope that helps


    Sreeharsha Alagani | MCTS Sharepoint 2010 | Linkedin | Blog

    • Proposed As Answer by Aviw_ Sunday, April 29, 2012 7:06 PM
    • Marked As Answer by Marreena Monday, April 30, 2012 7:39 AM
    •  
  • Monday, April 30, 2012 7:38 AM
     
     

    Many thanks sreeharsha,

    I have done it, i write code directly in "UpdateTask1" activity and it works like a charm. I tried this previously but i don't know why it didn't work before. But its working now. Thanks for saving my time :).

    • Edited by Marreena Monday, April 30, 2012 7:41 AM
    •