winforms
winforms copied to clipboard
Designer not loading: System.InvalidOperationException: Designer load encountered an error. Please ensure that the project can be built successfully.
Environment
Microsoft Visual Studio Enterprise 2022 (64-bit) - Preview Version 17.10.0 Preview 1.0
.NET version
.NET 8.0
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
</Project>
Did this work in a previous version of Visual Studio and/or previous .NET release?
Can't recall it worked
Issue description
Following commands were already exceuted.
Add-MpPreference -ExclusionProcess 'devenv.exe'
Add-MpPreference -ExclusionProcess 'DesignToolsServer.exe'
However, closing Visual Studio and reopening seems to solve the issue.
Steps to reproduce
- Create a Windows Forms Application
Diagnostics
[09:49:13.627374] info: Creating VsDesignerLoader
[09:49:13.718618] info: [Thread 1] Creating design-time ITypeResolutionService.
[09:49:13.756584] info: Start processing enqueued assemblies
[09:49:13.756584] trce: Loaded Microsoft.WinForms.DesignTools.Protocol in 00:00:00.0000078 [thread 69]
[09:49:13.757587] trce: Processed 'Microsoft.WinForms.DesignTools.Protocol' in 00:00:00.0008524
[09:49:13.759587] info: Added 'Microsoft.WinForms.DesignTools.Protocol'
[09:49:13.759587] trce: Loaded Microsoft.WinForms.DesignTools.Client in 00:00:00.0000059 [thread 69]
[09:49:13.765588] trce: Processed 'Microsoft.WinForms.DesignTools.Client' in 00:00:00.0053722
[09:49:13.766587] info: Added 'Microsoft.WinForms.DesignTools.Client'
[09:49:13.781584] info: BasicDesignerLoader.BeginLoad - Setting _loadDependencyCount to 0.
[09:49:13.783619] info: BasicDesignerLoader::BeginLoad - Calling AddLoadDependency
[09:49:13.787620] info: VsDesignerLoader::PerformLoad - Calling AddLoadDependency.
[09:49:13.790601] info: BasicDesignerLoader::BeginLoad - Calling DependentLoadComplete
[09:49:14.051632] info: Visual Studio culture: en-US (0x0409)
[09:49:14.051632] info: [Thread 10] Launching server...
[09:49:14.056631] info: Is processor architecture ARM64: False
[09:49:15.460926] info: Added 'mscorlib'
[09:49:15.460926] trce: Loaded System.Windows.Forms in 00:00:00.0000202 [thread 70]
[09:49:15.463925] trce: Processed 'System.Windows.Forms' in 00:00:00.0028683
[09:49:15.480926] info: Added 'System.Windows.Forms'
[09:49:15.480926] trce: Loaded System in 00:00:00.0000111 [thread 70]
[09:49:15.481923] trce: Processed 'System' in 00:00:00.0007721
[09:49:15.500607] info: Added 'System'
[09:49:15.500607] trce: Loaded System.Drawing in 00:00:00.0000076 [thread 70]
[09:49:15.500607] trce: Processed 'System.Drawing' in 00:00:00.0000938
[09:49:15.502608] info: Added 'System.Drawing'
[09:49:15.502608] trce: Loaded System.Design in 00:00:00.0000071 [thread 70]
[09:49:15.516231] trce: Processed 'System.Design' in 00:00:00.0142382
[09:49:15.527923] info: Added 'System.Design'
[09:49:15.527923] trce: Loaded System.Drawing.Design in 00:00:00.0000115 [thread 14]
[09:49:15.527923] trce: Processed 'System.Drawing.Design' in 00:00:00.0001963
[09:49:15.527923] info: Added 'System.Drawing.Design'
[09:49:16.329565] fail: OutputGroupService didn't return output group DesignerRuntimeImplementationProjectOutputGroup.
For information on how to troubleshoot the designer refer to the guide at https://aka.ms/winforms/designer/troubleshooting.
[09:49:16.329565] fail: Could not retrieve DesignerRuntimeImplementationProjectOutputGroup for current project.
For information on how to troubleshoot the designer refer to the guide at https://aka.ms/winforms/designer/troubleshooting.
[09:49:16.337555] fail: System.InvalidOperationException: Designer load encountered an error. Please ensure that the project can be built successfully.
at Microsoft.DotNet.DesignTools.Client.Host.ProjectInfoProvider.NetCore.<GetNetCoreProjectInfoAsync>d__6.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.ProjectInfoProvider.<GetProjectInfoAsync>d__9.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.
[09:49:16.359110] info: VsDesignerLoader::PerformLoad::LoadCompletionTask - Calling DependentLoadComplete.
[09:49:16.366109] warn: Cannot update selection in server process as Session is not connected.
@jaliyaudagedara The Form Designer can load and successfully with same Visual Studio version as below screenshot, could you please share more details with us to reproduce & investigate the issue?
@elachlan,
I am extremely sorry for the delay in responding.
Hmm, that's interesting. This is what I am seeing.
Let me see what else I can provide.
When I close the solution and open the solution back, it works. This is the output I am getting.
[22:24:01.965947] info: Creating VsDesignerLoader
[22:24:02.028950] info: [Thread 1] Creating design-time ITypeResolutionService.
[22:24:02.054458] info: Start processing enqueued assemblies
[22:24:02.054458] trce: Loaded Microsoft.WinForms.DesignTools.Protocol in 00:00:00.0000084 [thread 12]
[22:24:02.055458] trce: Processed 'Microsoft.WinForms.DesignTools.Protocol' in 00:00:00.0009117
[22:24:02.057459] info: Added 'Microsoft.WinForms.DesignTools.Protocol'
[22:24:02.057459] trce: Loaded Microsoft.WinForms.DesignTools.Client in 00:00:00.0000048 [thread 12]
[22:24:02.061458] trce: Processed 'Microsoft.WinForms.DesignTools.Client' in 00:00:00.0039299
[22:24:02.063457] info: Added 'Microsoft.WinForms.DesignTools.Client'
[22:24:02.079462] info: BasicDesignerLoader.BeginLoad - Setting _loadDependencyCount to 0.
[22:24:02.081462] info: BasicDesignerLoader::BeginLoad - Calling AddLoadDependency
[22:24:02.085461] info: VsDesignerLoader::PerformLoad - Calling AddLoadDependency.
[22:24:02.088461] info: BasicDesignerLoader::BeginLoad - Calling DependentLoadComplete
[22:24:02.196576] info: Visual Studio culture: en-US (0x0409)
[22:24:02.196576] info: [Thread 13] Launching server...
[22:24:02.202609] info: Is processor architecture ARM64: False
[22:24:02.468400] trce: Processed 'System.Windows.Forms' in 00:00:00.0021057
[22:24:02.483400] info: Added 'System.Windows.Forms'
[22:24:02.483400] trce: Loaded System in 00:00:00.0000111 [thread 46]
[22:24:02.484400] trce: Processed 'System' in 00:00:00.0008757
[22:24:02.499434] info: Added 'System'
[22:24:02.499434] trce: Loaded System.Drawing in 00:00:00.0000137 [thread 46]
[22:24:02.499434] trce: Processed 'System.Drawing' in 00:00:00.0001077
[22:24:02.500402] info: Added 'System.Drawing'
[22:24:02.500402] trce: Loaded System.Design in 00:00:00.0000077 [thread 46]
[22:24:02.509401] trce: Processed 'System.Design' in 00:00:00.0086444
[22:24:02.518439] info: Added 'System.Design'
[22:24:02.519407] trce: Loaded System.Drawing.Design in 00:00:00.0000157 [thread 42]
[22:24:02.519407] trce: Processed 'System.Drawing.Design' in 00:00:00.0002990
[22:24:02.519407] info: Added 'System.Drawing.Design'
[22:24:04.085030] info: Shadow cache base directory: C:\Users\Jaliya\AppData\Local\Microsoft\VisualStudio\17.0_a46c53aa\WinFormsDesigner
[22:24:04.093062] info: [WinFormsApp4]: Preparing shadow cache folder.
[22:24:04.094029] info: [WinFormsApp4]: NetCoreServerLayout - Platform: AnyCPU, Normalized PlatformName: x64
[22:24:04.097032] info: [WinFormsApp4]: Copying design tools server common files from: 'c:\program files\microsoft visual studio\2022\preview\common7\ide\commonextensions\microsoft\windows.forms\DesignToolsServer\Common'.
[22:24:04.126713] info: [WinFormsApp4]: Copying design tool server platform-specific files from: 'c:\program files\microsoft visual studio\2022\preview\common7\ide\commonextensions\microsoft\windows.forms\DesignToolsServer\x64'.
[22:24:04.134713] info: [WinFormsApp4]: Copying 'C:\Users\Jaliya\Desktop\WinFormsApp4\WinFormsApp4\obj\Debug\net8.0-windows\WinFormsApp4.designer.deps.json' to 'DesignToolsServer.deps.json'
[22:24:04.135713] info: [WinFormsApp4]: Copying 'C:\Users\Jaliya\Desktop\WinFormsApp4\WinFormsApp4\obj\Debug\net8.0-windows\WinFormsApp4.designer.runtimeconfig.json' to 'DesignToolsServer.runtimeconfig.json'
[22:24:04.319395] info: Shadow caching completed.
[22:24:04.324405] info: IServerConnectionTimeoutProvider: Starting execution of winFormsOptions task.
[22:24:04.325405] info: IServerConnectionTimeoutProvider: WinFormsOptions task completed.
[22:24:04.325405] info: Obtained ServerConnectionTimeout value: 120000.
[22:24:04.325405] info: Obtained OutputWindowLoggingService.
[22:24:04.331405] info: [WinFormsApp4]: Launching design tools server process...
[22:24:04.503081] info: [WinFormsApp4]: Connected to named pipe: DesignToolsServer.1271e971-1c1a-4cf0-9847-285ee60a0ec7
[22:24:04.572600] info: [WinFormsApp4]: Connecting to pipe: DesignToolsServer.1271e971-1c1a-4cf0-9847-285ee60a0ec7...
[22:24:04.572600] info: [WinFormsApp4]: Successfully connected to pipe: DesignToolsServer.1271e971-1c1a-4cf0-9847-285ee60a0ec7
[22:24:04.572600] info: [WinFormsApp4]: Creating DesignToolsServer [thread 1]
[22:24:04.572600] info: [WinFormsApp4]: Starting UI thread [thread 1]
[22:24:04.572600] info: [WinFormsApp4]: Performing start up tasks [thread 7]
[22:24:04.572600] info: [WinFormsApp4]: UI thread started
[22:24:04.572600] info: [WinFormsApp4]: Wait for start up tasks to complete... [thread 7]
[22:24:04.572600] info: [WinFormsApp4]: Loaded server manifest [thread 11]
[22:24:04.572600] info: [WinFormsApp4]: Loading design-time assemblies [thread 11]
[22:24:04.686778] info: [WinFormsApp4]: Building MEF composition
[22:24:04.936651] info: [WinFormsApp4]: Start up tasks completed [thread 11]
[22:24:04.936651] info: [WinFormsApp4]: Initialize JsonRpc [thread 11]
[22:24:04.956665] info: [WinFormsApp4]: Start processing enqueued assemblies
[22:24:04.956665] info: [WinFormsApp4]: Listening for JSON RPC messages
[22:24:04.956665] info: [WinFormsApp4]: Design tools server process is running
[22:24:04.956665] info: [WinFormsApp4]: Design tools server process launch completed successfully.
[22:24:04.956665] trce: [WinFormsApp4]: Launching and connecting to the design tools server process took 00:00:00.6276035
[22:24:04.958666] info: [Thread 29] DesignToolsServer launch time = 2761 ms.
[22:24:04.958666] info: [Thread 29] Initializing client...
[22:24:04.968665] info: [Thread 29] DesignToolsClient init time = 10 ms.
[22:24:04.968665] info: [Thread 29] Initializing server...
[22:24:04.974666] trce: [WinFormsApp4]: Loaded System.Private.CoreLib in 00:00:00.0000728 [thread 12]
[22:24:04.980666] trce: [WinFormsApp4]: Processed 'System.Private.CoreLib' in 00:00:00.0182154
...
And I can see the DesignerToolsServer
is running in Task Manager. But when I create a new project, DesignerToolsServer
is not there in Task Manager, so it's failing to start for some reason.
Updated Visual Studio to Visual Studio 17.10 – Preview 2
Microsoft Visual Studio Enterprise 2022 (64-bit) - Preview
Version 17.10.0 Preview 2.0
Same error!
But with more information this time.
Call Stack,
at Microsoft.DotNet.DesignTools.Client.Host.ProjectInfoProvider.NetCore.d__6.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.ProjectInfoProvider.d__9.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.d__9.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__29.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.<>c__DisplayClass25_1.<<-ctor>b__1>d.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__27.MoveNext()
@jaliyaudagedara , thanks for your response. still cannot reproduce it with latest Dev17 17.10.0 Preview 2.0 with .NET SDK 8.0.200, which bring in Visual Srudio, and .NET SDK 8.0.202 from https://dotnet.microsoft.com/en-us/download/dotnet/8.0 on win11 OS, the Form designer working well as below GIF. not sure what is the difference between you and me caused the issue. could you please have a try to repair or re-install the visual studio to see if which can work well?
Note: Did the same things on the win10 OS, which have the same results that the Form Designer working well.
.NET SDK 8.0.200
.NET SDK 8.0.202
I have repaired Visual Studio, still the same :(.
I am on Windows 11 Pro for Workstations
:
Not sure whether screen resolution matters:
A key thing is, when the solution is closed and re-opened, it works.
What's the difference? Isn't Stacktrace helpful?
Let me know if you want any specific logs from any internal folder.
I have reported the issue through Visual Studio Developer Community
, captured all the logs, and included them in the report.
Issue: Windows Forms Designer not loading: System.InvalidOperationException: Designer load encountered an error. Please ensure that the project can be built
P.S: there were a lot of reports for the issue. Seems I am not the only one who faced this issue and it has been happening for a couple of years.
Today got same problem but with existing old test .Net6 project. I've changed <TargetFramework>net6.0-windows</TargetFramework>
to net8.0-windows
in text editor and then launch VS. And designer not loading with exactly errors like here. More of it restart doesn't help. Then I decide to post here, changed WinFrorms VS logs to Information and restart VS once again - and designer was opened fine 🤷♂️Subsequent experiments failed to reproduce the problem :(
Please open VS2022 with administrator privileges first, and then open the solution from the VS project list, and the problem will disappear.
Although we can temporarily solve the problem in this way, VS2022 does have this bug, and the team has not fixed this problem yet. And this bug has existed for several years, but it has specific trigger conditions, and this trigger condition is unclear. We still hope the team can fix this bug if possible.
Please open VS2022 with administrator privileges first, and then open the solution from the VS project list, and the problem will disappear.
YES! very strange! i also will note that in the project that when run normally the form does not get a form.resx file created due to the crash. but after creating a new form then visual studio creates the .resx file that goes with the form. also the project structure is different from dot net 4.xx vs dot net core 8 i suspect that some details of the creation of a windows forms app with dot net 8 need to be checked out .... some privilege issues and what files to create in what locations are not fully right .....