Server Error in '/' Application.
--------------------------------------------------------------------------------Collection was modified; enumeration operation may not execute. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidOperationException: Collection was modified; enumeration operation may not execute.Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  Stack Trace: 
[InvalidOperationException: Collection was modified; enumeration operation may not execute.]
   System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource) +48
   System.Collections.Generic.Enumerator.MoveNext() +2480553
   MMS.Default_Left.CreateMenu() +1212
   MMS.Default_Left.Page_Load(Object sender, EventArgs e) +335
   System.Web.UI.Control.OnLoad(EventArgs e) +102
   System.Web.UI.Control.LoadRecursive() +47
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1064 
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50215.44; ASP.NET Version:2.0.50215.44

解决方案 »

  1.   

    Your problem is probably due to another thread modifying the list while you
    enumerate it.
    So, you need synchronization like:lock(tcClientList.SyncRoot)
    {
    foreach (TcClient tcClient in tcClientList)
    ...
    }
      

  2.   

    [InvalidOperationException: Collection was modified; enumeration operation may not execute.]
       System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource) +48
       System.Collections.Generic.Enumerator.MoveNext() +2480553
       MMS.Default_Left.CreateMenu() +1212
       MMS.Default_Left.Page_Load(Object sender, EventArgs e) +335
       System.Web.UI.Control.OnLoad(EventArgs e) +102
       System.Web.UI.Control.LoadRecursive() +47
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1064这是什么意思呢? 请各位讲讲…………
      

  3.   

    .net throw the Exception:InvalidOperationException
      

  4.   

    are you trying to do something likeArrayList al = ...;foreach (string s in al)
    {
      al.Remove(s);
    }?? don't do that, tryfor(int i=al.Count - 1; i>=0; i--)
    {
      string s = (string)al[i];
      al.Remove(s);
    }
      

  5.   

    解决方法:将bin目录放在根目录下即可