我们不能再在Designer中打开WinForms表单,因为我们从. NET 7切换到. NET 8的几天.它似乎与VS 2022版本无关,因为我的同事对比我的17.9.3更老的版本有同样的问题.修复没有帮助.我们正在编译"AnyCPU".

以下排除Windows Defender也没有帮助.

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

没有设置Switch.System.IO.UseLegacyPathHandling.

"Windows窗体输出"显示以下内容:

[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.

推荐答案

经过三天的诅咒,我发现了它,它是WinForms.DataVisualization(1.9.2)和Infragistics' Infragistics.WinForms.Charts(2023.2)的组合.似乎两个包都导出了一个"SeriesCollectionEditor"(?).移除其中一个或另一个后,一切都恢复正常.

.net相关问答推荐

为什么在WinForm应用程序中创建组件类椭圆会在www.example.com中没有响应

EGC / 文本元素上的 .NET String.Split

使用 PowerShell 从文件夹中获取文件名的最快\最好的方法是什么?

如何确定计时器是否正在运行?

移位比Java中的乘法和除法更快吗? .网?

Owin Twitter登录-根据验证程序远程证书无效

value 的默认参数必须是编译时间常数?

将客户端证书添加到 .NET Core HttpClient

BackgroundWorker 中未处理的异常

.NET 中工作线程和 I/O 线程的简单描述

如何将枚举值序列化为 int?

迭代器和枚举器的区别

.NET 进程间通信的最佳 Select 是什么?

DataGridView 在我的两个屏幕之一上的可怕重绘性能

C# 中的 override 和 new 关键字有什么区别?

string.Empty vs null.你用哪一个?

使 HashSet 不区分大小写

如何从 HashSet 中检索实际项目?

通过反射获取公共静态字段的值

如何将我的应用程序窗口置于最前面?