社内の winforms アプリケーションを VS2008 から VS2012 プロジェクトに変換して以来、winforms デザイナーの使用に問題があります。
デザイナーがエラー状態になり、次のエラー メッセージが表示されることがあります。
「コレクションが変更されました。列挙操作が実行されない可能性があります。」コールスタックは次のように言っています:
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)
おそらくいくつかの無効なアセンブリが原因で、デザイナーが参照されているアセンブリのリストを変更しようとしているようです。この問題を解決しようとしているときに、[プロジェクト] -> [プロパティ] -> [セキュリティ] の下にある [ClickOnce セキュリティを有効にする] オプションを変更すると、デザイナーが作業に戻ることができることがわかりました。しかし、オプションがオンになっていて、デザイナーのエラーが発生した場合、それをオフにして再構築すると、時々問題を解決できます。…というわけで、今ちょっと迷っています。