title: "Collection was modified; enumeration operation may not execute" When form closes
body: <p>I've seen a few questions regarding the <code>Collection was modified; enumeration operation may not execute.</code> error, but none of them fit my symptoms, and none of the solutions will fix my problem. Whats happening is when I close my form, at any point during runtime, a little messagebox pops up with that error. It doesn't really affect anything, but obviously I don't want an error popping up every time I close my form. Any clue what's causing this?</p>
  
  <p>I edited my manifest recently, so that could be the cause, I'm not too sure. I'll post it anyways. Thanks!</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
    &lt;assemblyIdentity version="1.0.0.0" name="MyApplication.app"/&gt;
    &lt;trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"&gt;
      &lt;security&gt;
        &lt;requestedPrivileges&gt;
          &lt;requestedExecutionLevel  level="requireAdministrator" uiAccess="false" /&gt;
        &lt;/requestedPrivileges&gt;
      &lt;/security&gt; 
    &lt;/trustInfo&gt;
  
    &lt;compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"&gt;
      &lt;application&gt;
        &lt;!-- A list of all Windows versions that this application is designed to work with. 
        Windows will automatically select the most compatible environment.--&gt;
  
        supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"
  
        supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"
  
        &lt;!-- If your application is designed to work with Windows 8, uncomment the following supportedOS node--&gt;
        &lt;!--&lt;supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"&gt;&lt;/supportedOS&gt;--&gt;
  
        &lt;!-- If your application is designed to work with Windows 8.1, uncomment the following supportedOS node--&gt;
        &lt;!--&lt;supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/&gt;--&gt;
  
      &lt;/application&gt;
    &lt;/compatibility&gt;
  
    &lt;!-- Enable themes for Windows common controls and dialogs (Windows XP and later) --&gt;
    &lt;!-- &lt;dependency&gt;
      &lt;dependentAssembly&gt;
        &lt;assemblyIdentity
            type="win32"
            name="Microsoft.Windows.Common-Controls"
            version="6.0.0.0"
            processorArchitecture="*"
            publicKeyToken="6595b64144ccf1df"
            language="*"
          /&gt;
      &lt;/dependentAssembly&gt;
    &lt;/dependency&gt;--&gt;
  
  &lt;/asmv1:assembly&gt;
  </code></pre>
  
  <p>Here is where the error occurs:</p>
  
  <pre><code>partial class MainMenu
      {
          /// &lt;summary&gt;
          /// Required designer variable.
          /// &lt;/summary&gt;
          private System.ComponentModel.IContainer components = null;
  
          /// &lt;summary&gt;
          /// Clean up any resources being used.
          /// &lt;/summary&gt;
          /// &lt;param name="disposing"&gt;true if managed resources should be disposed; otherwise, false.&lt;/param&gt;
          protected override void Dispose(bool disposing)
          {
              if (disposing &amp;&amp; (components != null))
              {
                  components.Dispose();
              }
              base.Dispose(disposing); //ERROR HAPPENS HERE
          }
              private System.Windows.Forms.Label label1;
          private Microsoft.VisualBasic.PowerPacks.ShapeContainer shapeContainer1;
          private Microsoft.VisualBasic.PowerPacks.RectangleShape rectangleShape1;
          private System.Windows.Forms.Button button1;
          private System.Windows.Forms.Button button2;
          private System.Windows.Forms.Button button3;
          private System.Windows.Forms.Button button4;
          private System.Windows.Forms.MenuStrip menuStrip1;
          private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
          private System.Windows.Forms.ToolStripMenuItem quitToolStripMenuItem;
          private System.Windows.Forms.Button button5;
          private System.Windows.Forms.ToolStripMenuItem profileToolStripMenuItem;
          private System.Windows.Forms.ToolStripMenuItem logInToolStripMenuItem;
          private System.Windows.Forms.ToolStripMenuItem logOutToolStripMenuItem;
          private System.Windows.Forms.ToolStripMenuItem createProfileToolStripMenuItem;
          private System.Windows.Forms.Button button6;
      }
  }
  </code></pre>
  
  <p>Exception stuff:</p>
  
  <pre><code>See the end of this message for details on invoking 
  just-in-time (JIT) debugging instead of this dialog box.
  
  ************** Exception Text **************
  System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
     at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
     at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
     at System.Collections.Generic.List`1.Enumerator.MoveNext()
     at Microsoft.VisualBasic.PowerPacks.ShapeCollection.Dispose(Boolean disposing)
     at Microsoft.VisualBasic.PowerPacks.ShapeContainer.Dispose(Boolean disposing)
     at System.ComponentModel.Component.Dispose()
     at System.Windows.Forms.Control.Dispose(Boolean disposing)
     at System.Windows.Forms.Form.Dispose(Boolean disposing)
     at POS_System.InventoryMenu.Dispose(Boolean disposing) in c:\Users\user\Desktop\Co-op\Co-op\C#\POS System\POS System\POS System\InventoryMenu.Designer.cs:line 20
     at System.ComponentModel.Component.Dispose()
     at System.Windows.Forms.Form.WmClose(Message&amp; m)
     at System.Windows.Forms.Form.WndProc(Message&amp; m)
     at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp; m)
     at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp; m)
     at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
  
  
  ************** Loaded Assemblies **************
  mscorlib
      Assembly Version: 4.0.0.0
      Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
      CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
  ----------------------------------------
  Point Of Sales
      Assembly Version: 1.0.0.0
      Win32 Version: 1.0.0.0
      CodeBase: file:///C:/Users/user/Desktop/Co-op/Co-op/C%23/POS%20System/POS%20System/POS%20System/bin/Debug/Point%20Of%20Sales.exe
  ----------------------------------------
  System.Windows.Forms
      Assembly Version: 4.0.0.0
      Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
      CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
  ----------------------------------------
  System.Drawing
      Assembly Version: 4.0.0.0
      Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
      CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
  ----------------------------------------
  System
      Assembly Version: 4.0.0.0
      Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
      CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
  ----------------------------------------
  System.Configuration
      Assembly Version: 4.0.0.0
      Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
      CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
  ----------------------------------------
  System.Xml
      Assembly Version: 4.0.0.0
      Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
      CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
  ----------------------------------------
  Microsoft.VisualBasic.PowerPacks.Vs
      Assembly Version: 10.0.0.0
      Win32 Version: 10.0.20911.1
      CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualBasic.PowerPacks.Vs/10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.PowerPacks.Vs.dll
  ----------------------------------------
  Microsoft.VisualBasic
      Assembly Version: 10.0.0.0
      Win32 Version: 11.0.50938.18408 built by: FX451RTMGREL
      CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualBasic/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
  ----------------------------------------
  System.Core
      Assembly Version: 4.0.0.0
      Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
      CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
  ----------------------------------------
  
  ************** JIT Debugging **************
  To enable just-in-time (JIT) debugging, the .config file for this
  application or computer (machine.config) must have the
  jitDebugging value set in the system.windows.forms section.
  The application must also be compiled with debugging
  enabled.
  
  For example:
  
  &lt;configuration&gt;
      &lt;system.windows.forms jitDebugging="true" /&gt;
  &lt;/configuration&gt;
  </code></pre>