views:

48

answers:

1

In the asp.net webservice, I have a static dataset that loads data (synchronized) upon first time access. However, when IIS recycle the app pool, I have exception thrown because of "Collection was modified; enumeration operation might not execute."

The recycle will start the new process, which will create new static dataset, the requests in old worker process will not access the new static dataset, how can the collection been modified? Or is that possible, the old worker process terminates immediately before the requests finish off?

Or do I understand the recycle process wrong? Rather than starting new worker process, IIS starts new AppDomain in the same worker process? and old and new appDomains sharing the same static dataset?

A: 

It turns out that this error isn't caused by recycle process. In the start up process, the synchronization prematurely returned the dataset to later request/thread, while the first request/thread is still populating the it, causing exception of "Collection was modified".

As it often does, I'm looking for key in the drawer I believe it should be in, while the key lies perfectly on the desk of the drawer. Sometimes, I'm just appalled that it is mind rather than eye actually sees. In this case, after I posted the question, I realized that I was looking at the wrong thing, simply because if it's caused by recycle process, I'm sure someone should already post the answer.

Thank you all! Zhen

Zhen.Lee