Search code examples
.netvisual-studiowinformswindows-forms-designer

Can't open WinForms forms anymore in Designer, VS2022, .NET 8


We can't open WinForms forms in Designer anymore since a couple of days during which we switched from .NET 7 to .NET 8. It seems not related to the VS 2022 version as my collegue has the same problem with an older version than my 17.9.3. Repair did not help. We are compiling to "AnyCPU".

The following excludes for Windows Defender didn't help either.

Add-MpPreference -ExclusionProcess 'devenv.exe'
Add-MpPreference -ExclusionProcess 'DesignToolsServer.exe'

Switch.System.IO.UseLegacyPathHandling is not set.

The "Windows Forms Output" shows the following:

[12:35:28.990802] warn: [NWWMain]: Encountered an additional TypeRoutingDefinition for 'Infragistics.Win.UltraWinGrid.GridControlCodeDomSerializer'
[12:35:28.999814] fail: [NWWMain]: Failed to launch design tools server process process
                        System.InvalidOperationException: Multiple instances of 'ICollectionEditorFactory' exported with the name 'SeriesCollectionEditor'.
                           at Microsoft.DotNet.DesignTools.Factories.ObjectFactoryManager`2.AddFactories(IEnumerable`1 factories, Boolean throwOnDuplicates)
                           at Microsoft.DotNet.DesignTools.Factories.ObjectFactoryManager`2..ctor(IEnumerable`1 factories)
                           at lambda_method1203(Closure, LifetimeContext, CompositionOperation)
                           at System.Composition.Hosting.Core.LifetimeContext.GetOrCreate(Int32 sharingId, CompositionOperation operation, CompositeActivator creator)
                           at System.Composition.TypedParts.ActivationFeatures.LifetimeFeature.<>c__DisplayClass1_0.<RewriteActivator>b__0(LifetimeContext c, CompositionOperation o)
                           at System.Composition.Hosting.Core.CompositionOperation.Run(LifetimeContext outermostLifetimeContext, CompositeActivator compositionRootActivator)
                           at System.Composition.Hosting.Core.LifetimeContext.TryGetExport(CompositionContract contract, Object& export)
                           at System.Composition.Hosting.CompositionHost.TryGetExport(CompositionContract contract, Object& export)
                           at System.Composition.CompositionContext.GetExport(CompositionContract contract)
                           at System.Composition.CompositionContext.GetExport(Type exportType, String contractName)
                           at System.Composition.CompositionContext.GetExport[TExport](String contractName)
                           at System.Composition.CompositionContext.GetExport[TExport]()
                           at Microsoft.WinForms.Utilities.Shared.Mef.CompositionHostExtensions.GetRequiredExport[TExport](CompositionHost compositionHost)
                           at Microsoft.DotNet.DesignTools.Server.DesignToolsServer.<StartUpAsync>g__AddMefServiceToContainer|48_0[T]()
                           at Microsoft.DotNet.DesignTools.Server.DesignToolsServer.StartUpAsync(Boolean testMode, CancellationToken cancellationToken)
                           at Microsoft.DotNet.DesignTools.Server.DesignToolsServer.StartListeningAsync(Stream stream, TraceListener traceListener)
                           at Microsoft.DotNet.DesignTools.Server.Program.<>c__DisplayClass2_0.<<Main>b__1>d.MoveNext()

                        For information on how to troubleshoot the designer refer to the guide at https://aka.ms/winforms/designer/troubleshooting.
[12:35:29.004803] fail: Microsoft.DotNet.DesignTools.Client.ServerException: Failed to launch the design tools server process.
                           at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                           at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
                           at Microsoft.VisualStudio.Threading.TplExtensions.<WithTimeout>d__5.MoveNext()
                        --- End of stack trace from previous location where exception was thrown ---
                           at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                           at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
                           at Microsoft.DotNet.DesignTools.Client.Host.ServerProcess.<LaunchAsync>d__28.MoveNext()
                        --- End of stack trace from previous location where exception was thrown ---
                           at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                           at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
                           at Microsoft.DotNet.DesignTools.Client.Host.ServerHostFactory.<CreateHostAsync>d__8.MoveNext()
                        --- End of stack trace from previous location where exception was thrown ---
                           at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                           at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
                           at Microsoft.DotNet.DesignTools.Client.DesignToolsClientLoader.<CreateClientAsync>d__29.MoveNext()

                        For information on how to troubleshoot the designer refer to the guide at https://aka.ms/winforms/designer/troubleshooting.
[12:35:29.023802] warn: Cannot update selection in server process as Session is not connected.
[12:35:59.643728] warn: Cannot update selection in server process as Session is not connected.

Solution

  • After three days cursing I found it out, it's the combination of WinForms.DataVisualization (1.9.2) and Infragistics' Infragistics.WinForms.Charts (2023.2). Seems like both packages export a "SeriesCollectionEditor" (?). After removing one or the other, everything works fine again.