Form Designer Error: Collection was modified; enumeration operation may not execute. - by MatthewTheMan

Status : 

 


7
0
Sign in
to vote
ID 781193 Comments
Status Closed Workarounds
Type Bug Repros 8
Opened 3/12/2013 6:10:00 AM
Access Restriction Public

Description

I attempt to design a form and get the following error:

Collection was modified; enumeration operation may not execute. 

Sometimes Visual Studio crashes; sometimes it doesn't
Sign in to post a comment.
Posted by Jain Nikhil on 3/12/2015 at 1:07 AM
Same issue i Got in 2013 when i Dipose Child Form from Master Page its Throw Exception Collection was modified; enumeration operation may not execute
Posted by TanyaSolyanik on 7/3/2014 at 9:49 AM
Hi Lijo John V.,
This is a different crash. The original post was about Visual Studio crashing in the Windows Forms designer, particularly see the following symbol on the stack: Microsoft.VisualStudio.Design.VSTypeResolutionService.
Are you getting this exception when you are running your application(F5) or when you are working in the Visual Studio designer on your application? Is the code snippet that you provided generated by the designer or is it your own code? Please investigate if you are regularly accessing your collection from multiple threads, maybe ConcurrentDictionary is a better choice for your program.
If this crash is in VisualStudio, please provide a sample application that shows this crash and open a new connect ticket.
Thank you,
The Windows Forms Team
Posted by Lijo John V on 7/3/2014 at 1:09 AM



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 System.Linq.Enumerable.WhereListIterator`1.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)

List<Customer> Customers =.......;
Customers.Where((C) => !C.IsDeleted).ToList()

Getting the same
Posted by Microsoft on 4/29/2014 at 12:29 PM
Thank you for reporting this issue. This issue has been fixed in Visual Studio 2013. You can install a trial version of Visual Studio 2013 with the fix from: http://go.microsoft.com/?linkid=9832436
Posted by Microsoft on 10/24/2013 at 4:34 PM
Hi J.PV,
Would you be able to upload a crash dump for the issue you are experiencing on VS2013
Thank you,
The Windows Forms Team
Posted by j.pv on 10/24/2013 at 4:17 PM
Getting this in VS2013 RTM when adding a code file to a C# MVC project....
Posted by Robert Breitenhofer on 9/11/2013 at 12:54 AM
Visual Studio 2012 Update 4 RC 3 is live now:

http://support.microsoft.com/kb/2872520/en-us | http://www.microsoft.com/en-us/download/details.aspx?id=40263

In the section [New technology improvements and fixed issues in Visual Studio 2012 Update 4 RC 3] under [Fixed issues] -> [Windows Forms] the following problem was fixed: „You may receive the following error message in Windows Forms Designer: Collection was modified; enumeration operation may not execute“ -> http://support.microsoft.com/kb/2872520/en-us
Posted by Microsoft on 5/24/2013 at 5:05 PM
Please contact customer support for a hotfix, or to escalate this bug for Visual Studio 2012 update 4 if you need this bug fixed before the next release. Just follow the regular process of opening a support case. For example, file online https://support.microsoft.com/oas/default.aspx?&gprid=548&&st=1&wfxredirect=1&sd=gn , select "Show all products.." and find Visual Studio under the "Tools" header, or call support http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone.
Thanks,
The Windows Forms Team
Posted by Microsoft on 5/24/2013 at 4:53 PM
Unfortunately there are no workarounds available.
Thanks,

The Windows Forms Team
Posted by Ant_Williams on 5/8/2013 at 8:07 AM
Are there any work arounds that we can use or hotfixes (even unsupported) that we can apply to avoid this issue? It is preventing me from working at the moment.
Or even just pointers about what can cause the issue so that I can change how my code is implemented.

Regards,
Anthony
Posted by Microsoft on 4/22/2013 at 5:32 PM
Thank you for your feedback. We are fixing the issue in the next release of Visual Studio.
To answer od5's question,(we don't need the dump any more), you can get detailed steps about how to get the dump file at http://blogs.msdn.com/debugger/archive/2009/12/30/what-is-a-dump-and-how-do-i-create-one.aspx

 
Many customers have found it useful to discuss issues like this in the forums (http://www.microsoft.com/communities/forums/default.mspx) where Microsoft and other members of the community can suggest workarounds.  Please keep the feedback coming.
 
Thanks,
The Windows Forms Team
Posted by MatthewTheMan on 4/8/2013 at 11:00 AM
I was able to capture the call stack today.

at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
at System.Collections.Generic.List`1.Enumerator.MoveNext()
at Microsoft.VisualStudio.Design.VSTypeResolutionService.AssemblySpecFound(List`1 assemblies, String assemblyFullName)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.AddDependencies(Assembly a, String fileName)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.AssemblyEntry.get_Assembly()
at Microsoft.VisualStudio.Design.VSTypeResolutionService.AssemblyEntry.Search(String fullName, String typeName, Boolean ignoreTypeCase, Boolean allowPrivate, Assembly& assembly, String description)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.AssemblyEntry.Search(String fullName, String typeName, Boolean ignoreTypeCase, Assembly& assembly, String description)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.SearchNormalEntries(AssemblyName assemblyName, String typeName, Boolean ignoreTypeCase, Assembly& assembly, Boolean fastSearch)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.SearchEntries(AssemblyName assemblyName, String typeName, Boolean ignoreCase, Assembly& assembly, ReferenceType refType)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, ReferenceType refType)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.AggregateTypeResolutionService.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.AggregateTypeResolutionService.GetType(String name)
at System.ComponentModel.Design.DesignerHost.System.ComponentModel.Design.IDesignerHost.GetType(String typeName)
at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.EnsureDocument(IDesignerSerializationManager manager)
at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.DeferredLoadHandler.Microsoft.VisualStudio.TextManager.Interop.IVsTextBufferDataEvents.OnLoadCompleted(Int32 fReload)
Posted by od5 on 4/3/2013 at 8:13 AM
I've attached two screen shots showing the error, one has an "Ingore and Continue" option; the other does not. As I noted below, I can find no logic to the sequence of solution tasks (rebuild, close/reopen, check in/out) that produces one or other of these (or other "random" variants, including different errors and -- rarely -- just succesful opening of designer).
Posted by od5 on 4/3/2013 at 7:57 AM
I am not the original reporter of this bug, but I definitely can reproduce it & would like to submit more information to help Microsoft resolve it.

You ask for a dump file. However, as MatthewTheMan points out, this bug does not occur when running the application, but rather in the Visual Studio Designer, which displays an error page for "problem" forms, rather than displaying the design. No dump file is available, nor is the menu option Debug / Save Dump As (since the debugger is not running).

Do you have any suggestions as to how to how to provide VS Design-Time dumps or other helpful error details?

Thanks.
Posted by Microsoft on 4/3/2013 at 2:13 AM
Hi MatthewTheMan, we want to remind you we have sent new comments to you. We can't repro this issue, so we need more information to help us investigate it. Please reply to us in time. Thanks for your time.
Posted by Microsoft on 3/31/2013 at 11:41 PM
Hi MatthewTheMan, could you upload a 32 dump file to us please?
Please open the following link to create a dump file.
http://blogs.msdn.com/b/debugger/archive/2009/12/30/what-is-a-dump-and-how-do-i-create-one.aspx .
You also can create it through feedback tool.
1. Start Microsoft Visual Studio 2012 Feedback Tool
2. Select "Add to an existing feedback"
3. Select type: Hang
The dump file may be too large to attach, please upload it into the following workspace.
************************************************************
Please zip the file and use "FeedbackID-781193" as prefix of the file name.
************************************************************
You can use the following workspace to upload the file by IE: https://sftemea.one.microsoft.com/choosetransfer.aspx?key=4714c7a4-1646-49f2-8e2c-91f818cdd165
Password: g#8EJcuGOqrKZ8N
Thanks again for your efforts and we look forward to hearing from you.

Posted by Microsoft on 3/29/2013 at 9:48 AM
Thank you for sharing the exception stack. Would you be able to upload a dump as well?
Thanks,
The Windows Forms Product Team
Posted by Microsoft on 3/29/2013 at 9:48 AM
Thank you for sharing the exception stack. Would you be able to upload a dump as well?
Thanks,
The Windows Forms Product Team
Posted by od5 on 3/28/2013 at 1:24 PM
I have the same (or very similar) problem, and it is maddeningly erratic and show-stopping. Many user controls in my solution (which derive from and/or include user controls from other projects in the solution) will SOMETIMES fail to open in the VS2012 designer with the error (usually) "Collection was modified; enumeration operation may not execute." [Never had this problem in VS2005 with the same solution]. SOMETIMES, but not always, "Ingore and Continue" is an available option. SOMETIMES, but not always, one or other of the following, in combination will allow me to open the control in the designer: rebuild solution, close and reopen VS2012, delete contents of obj folders. Sooner or later, somehow, I get the "Ignore and Continue" option and can open the designer. I have not been able to identify any rhyme or reason to the scenarios. None of the constructors in the chain is accessing (as far as I can tell) any external resources or doing any complex initializations.

An example call stack from the VS error page is pasted below. There is no information of which (if any) of the child controls or collections on the control that won't open is actually causing the problem.

at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
at System.Collections.Generic.List`1.Enumerator.MoveNext()
at Microsoft.VisualStudio.Design.VSTypeResolutionService.AssemblySpecFound(List`1 assemblies, String assemblyFullName)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.AddProjectDependencies(Project project)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.AssemblyEntry.get_Assembly()
at Microsoft.VisualStudio.Design.VSTypeResolutionService.AssemblyEntry.Search(String fullName, String typeName, Boolean ignoreTypeCase, Boolean allowPrivate, Assembly& assembly, String description)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.AssemblyEntry.Search(String fullName, String typeName, Boolean ignoreTypeCase, Assembly& assembly, String description)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.SearchProjectEntries(AssemblyName assemblyName, String typeName, Boolean ignoreTypeCase, Assembly& assembly)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.SearchEntries(AssemblyName assemblyName, String typeName, Boolean ignoreCase, Assembly& assembly, ReferenceType refType)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.SearchEntries(AssemblyName assemblyName, String typeName, Boolean ignoreTypeCase, Assembly& assembly)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.System.ComponentModel.Design.ITypeResolutionService.GetAssembly(AssemblyName name, Boolean throwOnError)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.System.ComponentModel.Design.ITypeResolutionService.GetAssembly(AssemblyName name)
at Microsoft.VisualStudio.Design.VSDynamicTypeService.OnAssemblyResolve(Object sender, ResolveEventArgs e)
at System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)
Posted by Microsoft on 3/27/2013 at 7:46 PM
Hi MatthewTheMan, Thanks for your response. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by MatthewTheMan on 3/20/2013 at 5:08 AM
The original exception is
is from this line of code:at System.ComponentModel.Component.Finalize()

here is the exception

     InnerException: System.InvalidOperationException
            HResult=-2146233079
            Message=Collection was modified; enumeration operation may not execute.
            Source=System
            StackTrace:
                 at System.ComponentModel.ReflectPropertyDescriptor.SetValue(Object component, Object value)
                 at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkPropertyDescriptor.SetValue(Object component, Object value)
                 at System.ComponentModel.Design.InheritedPropertyDescriptor.SetValue(Object component, Object value)
                 at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializePropertyAssignStatement(IDesignerSerializationManager manager, CodeAssignStatement statement, CodePropertyReferenceExpression propertyReferenceEx, Boolean reportError)
                 at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeAssignStatement(IDesignerSerializationManager manager, CodeAssignStatement statement)
                 at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager manager, CodeStatement statement)
            InnerException:
Posted by MatthewTheMan on 3/19/2013 at 12:58 PM
what is the best way to get a dump file? The last few times no dump file was generated that I could find. Visual Studio crashed an restarted.

I did see the following error in the event viewer:

Application: devenv.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.TypeInitializationException
Stack:
at xxxMyUserControlxxxxx.Dispose(Boolean)
at System.ComponentModel.Component.Finalize()


The dispose method only has the generated code; and this is during design time.


this is followed by

Faulting application name: devenv.exe, version: 11.0.51106.1, time stamp: 0x5098c6d7
Faulting module name: KERNELBASE.dll, version: 6.1.7601.18015, time stamp: 0x50b83c8a
Exception code: 0xe0434352
Fault offset: 0x0000c41f
Faulting process id: 0x2ec4
Faulting application start time: 0x01ce24d81dceb28d
Faulting application path: C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe
Faulting module path: C:\Windows\syswow64\KERNELBASE.dll
Report Id: 8a636f2a-90cb-11e2-baa1-bb04872e08ba

Posted by Microsoft on 3/13/2013 at 12:18 AM
Thank you for submitting feedback on Visual Studio and .NET Framework. In order to efficiently investigate and reproduce this issue, we are requesting a 32 bits dump file. We look forward to hearing from you with this information.
If the dump file is too big to upload, please upload it into following workspace
************************************************************
Please zip the file and use "FeedbackID-XXXXXX" as prefix of the file name.
************************************************************
You can use the following workspace to upload the file by IE: https://sftemea.one.microsoft.com/choosetransfer.aspx?key=4714c7a4-1646-49f2-8e2c-91f818cdd165
Password: g#8EJcuGOqrKZ8N
Thanks again for your efforts and we look forward to hearing from you.
Posted by Microsoft on 3/12/2013 at 10:45 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)