由於將我們的公司內部winforms應用程序從VS2008轉換爲VS2012項目,我在使用winforms設計器時遇到了問題。收藏已修改;枚舉操作可能無法在VS WinForms Designer中執行
有時候設計師陷入錯誤狀態給出以下錯誤消息:
「集合被修改;枚舉操作可能不會執行。」與調用堆棧說:
Instances of this error (1)
1. Hide Call Stack
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.SearchByShortName(String partialName, String fullName, AssemblyEntry[] entries, Assembly& assembly)
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.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)
似乎設計師正試圖改變引用的程序集的列表,可能是因爲一些無效的程序集。 在試圖解決這個問題時,我發現改變Project-> Properties-> Security下的「啓用ClickOnce安全性」選項可以讓設計人員恢復工作。但如果該選項打開,我得到設計師的錯誤關閉和重建所有可以不時解決問題和VICE VERSA !!!! ...這就是爲什麼我現在有點迷路了。
也許你應該先嚐試升級到2010年。 :/ – 2013-05-10 08:35:52
在引發異常之前,集合已被修改*。所以這個callstack根本不會幫你。完全不清楚您的表單可能會導致此異常。 – 2013-05-10 10:14:58