"集合已修改;枚举操作可能不会执行"部署错误 [英] "Collection was modified; enumeration operation may not execute" error on deployment

查看:27
本文介绍了"集合已修改;枚举操作可能不会执行"部署错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在部署 VB.NET 应用程序时遇到此错误,我一生都无法弄清楚原因.

I'm getting this error when I deploy a VB.NET application and for the life of me I cannot figure out why.

当我从 IDE 运行应用程序时,我没有收到此错误,而我正在部署它的测试机器具有与开发机器类似的配置...Windows 7 &.NET 3.51 SP1 和 4.0.

I do not get this error when I run the app from the IDE and the test machine I am deploying it to has a similar configuration to the dev machine...Windows 7 & .NET 3.51 SP1 and 4.0.

登录后加载主表单时应用程序会爆炸.我已将范围缩小到主表单,因为如果我从登录加载另一个表单然后打开主表单,就会发生这种情况.

The app bombs out when the main form is loaded after logging in. I've narrowed it down to the main form because if I load another form from login and then open the main form, this happens.

下面链接是堆栈跟踪的屏幕截图.

Linked below is a screenshot of the stack trace.

有什么想法吗?我真的迷路了.

Any ideas? I'm really lost here.

谢谢.

推荐答案

我没有看到 ShapeCollection.Dispose() 抛出该异常的方法.尽管它正在操纵一个确实可以抛出该异常的 List<>,但代码不应触发它:

I do not see a way for ShapeCollection.Dispose() to throw that exception. Although it is manipulating a List<> that can indeed throw that exception, the code should not trigger it:

private void Dispose(bool disposing)
{
    if (!this.m_Disposed && disposing)
    {
        for (int i = this.m_Shapes.Count - 1; i >= 0; i--)
        {
            this.m_Shapes[i].Dispose();
        }
        this.m_Shapes.Clear();
        this.m_Shapes = null;
    }
    this.m_Disposed = true;
}

嗯,这是我拥有的 PowerPacks 版本.它有几个版本,以前是分开分发的.确保您没有意外部署旧版本.

Well, this is from the PowerPacks version that I have. There have been a couple of versions of it floating around, it used to be distributed separately. Make sure you didn't accidentally deploy an old version.

这篇关于&quot;集合已修改;枚举操作可能不会执行"部署错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆