IIS回收导致静态数据集访问错误

发布于 2024-09-12 04:35:37 字数 274 浏览 6 评论 0原文

在 asp.net web 服务中,我有一个静态数据集,可以在第一次访问时加载数据(同步)。但是,当 IIS 回收应用程序池时,我会抛出异常,因为“集合已修改;枚举操作可能无法执行”。

回收将启动新进程,该进程将创建新的静态数据集,旧工作进程中的请求将不会访问新的静态数据集,如何修改集合?或者这有可能吗,旧的工作进程在请求完成之前立即终止?

还是我对回收过程的理解错误? IIS 在同一个工作进程中启动新的 AppDomain,而不是启动新的工作进程?新旧 appDomain 共享相同的静态数据集?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

三寸金莲 2024-09-19 04:35:37

事实证明,这个错误不是由回收过程引起的。在启动过程中,同步过早地将数据集返回给后面的请求/线程,而第一个请求/线程仍在填充它,导致“Collection was Modified”异常。

像往常一样,我在抽屉里寻找钥匙,我相信它应该在里面,而钥匙正好放在抽屉的桌子上。有时,我只是感到震惊,因为真正看到的是心灵而不是眼睛。在这种情况下,在我发布问题后,我意识到我正在寻找错误的东西,仅仅是因为如果它是由回收过程引起的,我确信有人应该已经发布了答案。

谢谢大家!

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文