Collection was modified; enumeration operation may not execute.

  • 25 August 2015
  • 3 replies
  • 21 views

Badge +10

Hi all

 

I have a custom method that starts a workflow process. I intermittently get this error.

Collection was modified; enumeration operation may not execute.

According to the stack trace it occurs in the StartProcessInstance method. Anything above the third line is K2 code, and that is where it seems to be throwing the error. Just wondering if anyone has had a similar issue. I have read some post on programming forum and the general error seems to be when you modify the object you are currently looping. But I don’t know what code is being executed where this stack trace is pointing.

at SourceCode.Workflow.Client.InternalConnection.Call(ArchiveX ar, MessageType msgtype)
at SourceCode.Workflow.Client.Connection.StartProcessInstance(ProcessInstance ProcInst, Boolean Sync)
at MyCustomServiceObject.MyCustomStartProcessMethod()

 

Any help would be appreciated.

 


3 replies

Userlevel 5
Badge +16

Hi s0m3one,

 

This typically happens when assigning permissions to groups with a very large number of users.

 

There is a known issue where the following error: "System.Exception: Collection was modified; enumeration operation may not execute" can occur when K2 Process Rights have been assigned to large AD groups such as ’Domain Users’. The issue has been fixed in KB001230

Badge +10

HI Mustafa,

 

Good to hear, its been fixed but we are on 4.6.9. I belive KB001230 is 4.5. Please correct me if thats wrong Although, I guess they are related, because most of the time the user starting the process is a user in the domain users group. And that is about 5000 - 20000 users depending on domain. Any ideas , please let me know.

 

Thanks

 

Badge +10

Hi,

 

We received this the other day on our 4.6.9 environment when viewing viewflow.

I did not find anything in the logs but the server was running low on memory.

I recycled app pools and gave the K2 server a bounce which seemed to have resolved it.

I think it might be due to memory load causing something to happen inside the K2 server.

Since there are no further logging it is difficult to pin down exactly what could have caused it, but hopefully this works for you too.

 

Regards,

JohanL

Reply