dotnet / winforms

Windows Forms is a .NET UI framework for building Windows desktop applications.
MIT License
4.41k stars 984 forks source link

WinForms Designer not loading #6705

Closed smohanty05 closed 2 years ago

smohanty05 commented 2 years ago

I have a solution file with 100+ projects. It is taking 1-5 to 2 minutes load a designer for a project. Other WinForm of the same project then loads quickly. But if we restart VS or reload project or make any changes to the project, then next WinForm load again taking 1-5 to 2 minutes. Also I saw one case where it is not loading at all. Open one WinForm of Project1. While waiting, load another WinForm of Project2. After waiting for around 2 minutes, Project2 form designer opens. But Project1 form designer does not open at all. Even closing both forms and reopening Project1 form also does not solve it. Wokaround: restart Visual Studio open the Project1 designer.

Hope you will resolve such issues.

Expected behavior:

WinForms designer should load always and also should not take long time to load.

Minimal repro:

Open one WinForm of Project1. While waiting, load another WinForm of Project2. After waiting for around 2 minutes, Project2 form designer opens. But Project1 form designer does not open at all. Even closing both forms and reopening Project1 form also does not solve it.

After that I tried couple of times, even after restating VS, Winforms not loading. Getting below error: [02:56:01.4218652] Processed 'System.Design' in 00:00:00.1833175 [02:56:01.4788618] Added 'System.Design' [02:56:01.4788618] Loaded System.Drawing.Design in 00:00:00.0000201 [thread 30] [02:56:01.4818653] Processed 'System.Drawing.Design' in 00:00:00.0033208 [02:56:01.4838625] Added 'System.Drawing.Design' [02:56:01.4988609] Creating VSCodeDomDesignerLoader [02:56:03.3968614] Current VS Version = 17.0 [02:56:03.4029064] Start processing enqueued assemblies [02:56:05.4728612] Loaded Microsoft.WinForms.DesignTools.Protocol in 00:00:00.0000229 [thread 15] [02:56:05.4728612] Processed 'Microsoft.WinForms.DesignTools.Protocol' in 00:00:00.0000847 [02:56:05.4758617] Added 'Microsoft.WinForms.DesignTools.Protocol' [02:56:05.4768616] Loaded Microsoft.WinForms.DesignTools.Client in 00:00:00.0000129 [thread 15] [02:56:05.4768616] Processed 'Microsoft.WinForms.DesignTools.Client' in 00:00:00.0000517 [02:56:05.4788609] Added 'Microsoft.WinForms.DesignTools.Client' [02:56:26.4448613] [TestProj]: Preparing shadow cache folder [02:56:26.5018603] [TestProj]: Copying design tools server common files from: 'c:\program files\microsoft visual studio\2022\professional\common7\ide\commonextensions\microsoft\windows.forms\DesignToolsServer\Common' [02:56:43.1938610] [TestProj]: Copying design tool server platform-specific files from: 'c:\program files\microsoft visual studio\2022\professional\common7\ide\commonextensions\microsoft\windows.forms\DesignToolsServer\x64' [02:56:43.7488646] [TestProj]: Copying project output folder from: 'C:\Users\admin\Test\Core\Goods\Debug\net6.0-windows'

[02:59:02.5368609] [TestProj]: Launching design tools server process... [02:59:10.6518617] [TestProj]: Connected to named pipe: DesignToolsServer.8e987606-f748-4d4d-85e1-8371114185ed [02:59:10.6718605] [TestProj]: info: Design Tools Server[0] [02:59:10.6718605] [TestProj]: Connecting to pipe: DesignToolsServer.8e987606-f748-4d4d-85e1-8371114185ed... [02:59:10.6868563] [TestProj]: info: Design Tools Server[0] [02:59:10.6868563] [TestProj]: Successfully connected to pipe: DesignToolsServer.8e987606-f748-4d4d-85e1-8371114185ed [02:59:10.6868563] [TestProj]: info: Microsoft.DotNet.DesignTools.Server.DesignToolsServer[0] [02:59:10.6868563] [TestProj]: Creating DesignToolsServer [thread 1] [02:59:10.6988609] [TestProj]: info: Microsoft.DotNet.DesignTools.Server.DesignToolsServer[0] [02:59:10.6988609] [TestProj]: Performing start up tasks [thread 7] [02:59:10.7178614] [TestProj]: info: Microsoft.DotNet.DesignTools.Server.DesignToolsServer[0] [02:59:10.7178614] [TestProj]: Starting UI thread [thread 1] [02:59:11.3908585] [TestProj]: info: Design Tools Server[0] [02:59:11.3908585] [TestProj]: UI thread started [02:59:11.4128615] [TestProj]: info: Microsoft.DotNet.DesignTools.Server.DesignToolsServer[0] [02:59:11.4128615] [TestProj]: Wait for start up tasks to complete... [thread 8] [02:59:11.9358620] [TestProj]: info: Microsoft.DotNet.DesignTools.Server.DesignToolsServer[0] [02:59:11.9358620] [TestProj]: Loaded server manifest [thread 7] [02:59:11.9468571] [TestProj]: info: Microsoft.DotNet.DesignTools.Server.DesignToolsServer[0] [02:59:11.9468571] [TestProj]: Loading design-time assemblies [thread 7] [02:59:18.6108583] [TestProj]: info: Microsoft.DotNet.DesignTools.Server.ServerProtocolContext[0] [02:59:18.6118592] [TestProj]: Building MEF composition [02:59:20.7198643] [TestProj]: Timed out waiting for the design tools server process launch to complete. [02:59:20.7668637] Microsoft.DotNet.DesignTools.Client.ServerException: Timed out waiting for the design tools server process launch to complete. at Microsoft.DotNet.DesignTools.Client.Host.ServerProcess.d25.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.d7.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.d__35.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)

Error seen when opening any other WinForm of different project. Then I again reloaded project and this time it opened.

So the behavior is not consistent.

RussKie commented 2 years ago

The log shows that it's taking nearly 3 minutes to launch the designer server process (from 02:56:26.4448613 to 02:59:20.7668637), most of which appears related to the copying of the necessary artifacts. Some users reported that adding exclusions for the DesignToolsServer to their AV services has resulted in measurable increase of the designer launch, e.g., https://github.com/dotnet/winforms/issues/6420#issuecomment-1013239834.

I have good news and a bad news for you.

The good news are that in VS 2022 17.1p5 we have bumped the connection timeout from 10 seconds to 2 minutes, and in VS 2022 17.2 we have added the ability to increase the connection timeout, which should help in your case. The bad news is that you will have to wait for the 17.2.