错误:集合已修改;枚举操作可能无法执行. [英] error:Collection was modified; enumeration operation may not execute.
本文介绍了错误:集合已修改;枚举操作可能无法执行.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发桌面应用程序.
完成开发应用程序后,将其复制并粘贴到另一个系统中.
并将其运行到该系统,它会提供以下错误:
I''m developing desktop application.
When I complete developed my application.and copy and paste to another system.
and run it to that system, it provide following error:
Collection was modified; enumeration operation may not execute. in particular line of .Designer.cs FILE
<pre lang="cs">protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
我该怎么解决?
任何人都可以帮助我!
提前谢谢.
[edit]添加了代码块以突出显示错误和代码,标点符号.呼喊已删除.所有首都都被认为在互联网上大喊大叫(和粗鲁). -OriginalGriff [/edit]
How can I solve it?
Any one help me please!
Thanks in advance.
[edit]Code blocks added to highlight error and code, punctuation. SHOUTING removed. All capitals is considered shouting (and rude) on the internet. - OriginalGriff[/edit]
推荐答案
仅凭单行代码就很难准确地找到它,而没有任何周围的上下文,但是此错误消息通常表示您正在尝试从foreach
循环中删除列表的元素.
您不能这样做:它将使迭代混乱到下一个元素.改为将其转换为for
循环.
It is difficult to be precise from just a single line of code without any surrounding context, but this error message normally means you are trying to remove an element of a list from within aforeach
loop.
You can''t do that: it would mess up the iteration to the next element. Convert it to afor
loop instead.
该线程还讨论了类似的问题.如果您没有看到此问题,请看一下.它可能会对您有所帮助.
http://social.msdn.microsoft.com/论坛/en-US/csharpgeneral/thread/3dfacbe5-ae9c-4bbe-9686-dea084edfdc3 [
This thread talks about a similar problem.Please have a look if you haven''t seen this.It may help you.
http://social.msdn.microsoft.com/forums/en-US/csharpgeneral/thread/3dfacbe5-ae9c-4bbe-9686-dea084edfdc3[^]
这篇关于错误:集合已修改;枚举操作可能无法执行.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文