dotnet / winforms

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

Microsoft.DotNet.DesignTools.Client.DesignToolsServerException: Could not resolve type, 'System.ComponentModel.ComponentEditor #11650

Open PLDAWOL opened 2 months ago

PLDAWOL commented 2 months ago

Environment

Microsoft Visual Studio Professional 2022 Version 17.10.1 VisualStudio.17.Release/17.10.1+34928.147

.NET version

.NET 8.0

Did this work in a previous version of Visual Studio and/or previous .NET release?

.NET 4.6.1, .NET 4.7.2, .NET 4.8 .NetStandard 2.0

Issue description

I am writing on behalf of one of the project teams from Hitachi Energy, one of the partners of Microsoft.

After upgrade of our WinForms application projects from .NET 4.8 to .NET 8 we observed, that we are not able to edit WinForms using Designer anymore; we cannot add, move, remove or edit Properties of the controls.

We have followed some of the workarounds, but due to the sheer amount of projects (more than +100 in a solution) in our 20-year old app we haven't been succesful with this.

For single projects with forms when removed some of the project dependencies, then WinForms became editable again via OOP Designer.

We observed that for some reason the dependencies in our runtime somehow collide with OOP Designer dependencies or the logs are hiding some other problem while wrongly pointing out that the exception happens in the DesignServerTools.exe

Please advice how we could further approach troubleshooting such issue.

Due to confidentiality of content I was not able to produce project for repro. Also we do not know what we would need to reproduce, as we struggle to pinpoint what causes the issue.

Steps to reproduce

  1. Open with double-click form
  2. In OOP Designer right click on any of the controls
  3. Select Properties
  4. In Windows Forms output set to Verbose we can observe the attached log entries image image

Diagnostics

14:14:32:903    [14:14:32.836962] trce: Sending request: Input/InputMessage
14:14:32:903    [14:14:32.837974] trce: Input/InputMessage took 00:00:00.0009551.
14:14:32:903    [14:14:32.852963] trce: Sending request: Input/InputMessage
14:14:32:903    [14:14:32.852963] trce: Input/InputMessage took 00:00:00.0008268.
14:14:32:903    [14:14:32.858963] trce: Sending request: Input/InputMessage
14:14:32:903    [14:14:32.858963] trce: Input/InputMessage took 00:00:00.0006044.
14:14:32:903    [14:14:32.868964] trce: Sending request: Input/InputMessage
14:14:32:903    [14:14:32.868964] trce: Input/InputMessage took 00:00:00.0006919.
14:14:32:903    [14:14:32.876962] trce: Sending request: Input/InputMessage
14:14:32:903    [14:14:32.877974] trce: Input/InputMessage took 00:00:00.0007527.
14:14:32:903    [14:14:32.891962] trce: Sending request: Input/InputMessage
14:14:32:903    [14:14:32.892965] trce: Input/InputMessage took 00:00:00.0005079.
14:14:33:015    [14:14:32.911966] trce: Sending request: Input/InputMessage
14:14:33:015    [14:14:32.911966] trce: Input/InputMessage took 00:00:00.0005723.
14:14:33:015    [14:14:32.932739] trce: Sending request: Input/InputMessage
14:14:33:015    [14:14:32.933740] trce: Input/InputMessage took 00:00:00.0007435.
14:14:33:015    [14:14:32.989240] trce: Sending request: Input/InputMessage
14:14:33:015    [14:14:32.990240] trce: Input/InputMessage took 00:00:00.0009027.
14:14:33:152    [14:14:33.060998] trce: Sending request: Input/InputMessage
14:14:33:152    [14:14:33.060998] trce: Input/InputMessage took 00:00:00.0006911.
14:14:33:152    [14:14:33.068007] trce: Sending request: Input/InputMessage
14:14:33:152    [14:14:33.068998] trce: Input/InputMessage took 00:00:00.0005996.
14:14:33:152    [14:14:33.077002] trce: Sending request: Input/InputMessage
14:14:33:152    [14:14:33.077002] trce: Input/InputMessage took 00:00:00.0006380.
14:14:33:152    [14:14:33.085007] trce: Sending request: Input/InputMessage
14:14:33:152    [14:14:33.086003] trce: Input/InputMessage took 00:00:00.0005998.
14:14:33:152    [14:14:33.093000] trce: Sending request: Input/InputMessage
14:14:33:152    [14:14:33.093000] trce: Input/InputMessage took 00:00:00.0006006.
14:14:33:152    [14:14:33.109005] trce: Sending request: Input/InputMessage
14:14:33:152    [14:14:33.109005] trce: Input/InputMessage took 00:00:00.0006546.
14:14:33:264    [14:14:33.125014] trce: Sending request: Input/InputMessage
14:14:33:264    [14:14:33.125014] trce: Input/InputMessage took 00:00:00.0007383.
14:14:33:264    [14:14:33.150532] trce: Sending request: Input/InputMessage
14:14:33:264    [14:14:33.151532] trce: Input/InputMessage took 00:00:00.0008021.
14:14:33:346    [14:14:33.246135] trce: Sending request: Input/InputMessage
14:14:33:346    [14:14:33.246135] trce: [CDSUI]: Attempting to update selection: 1 components, Primary
14:14:33:346    [14:14:33.246135] trce: [CDSUI]: Made change: False
14:14:33:346    [14:14:33.247133] trce: Input/InputMessage took 00:00:00.0009849.
14:14:33:346    [14:14:33.250139] trce: Sending request: Input/InputMessage
14:14:33:346    [14:14:33.251136] trce: Input/InputMessage took 00:00:00.0006114.
14:14:33:484    [14:14:33.362696] trce: Sending request: Input/InputMessage
14:14:33:484    [14:14:33.363705] trce: Input/InputMessage took 00:00:00.0010789.
14:14:33:484    [14:14:33.363705] trce: Sending request: ComponentTrays/IsInBounds
14:14:33:484    [14:14:33.364699] trce: ComponentTrays/IsInBounds took 00:00:00.0006270.
14:14:35:411    [14:14:35.354816] trce: Sending request: Types/GetEditor
14:14:35:411    [14:14:35.354816] info: [CDSUI]: TypeResolution: type = System.Windows.Forms.Form, TimeTaken = 0 ms.
14:14:35:411    [14:14:35.354816] info: [CDSUI]: TypeResolution: type = System.ComponentModel.ComponentEditor not found, TimeTaken = 0 ms.
14:14:35:411    [14:14:35.355815] trce: Types/GetEditor took 00:00:00.0011086.
14:14:35:411    [14:14:35.356826] fail: Request failures: Types/GetEditor.
14:14:35:411                            Microsoft.DotNet.DesignTools.Client.DesignToolsServerException: Could not resolve type, 'System.ComponentModel.ComponentEditor, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
14:14:35:411    
14:14:35:411                            For information on how to troubleshoot the designer refer to the guide at https://aka.ms/winforms/designer/troubleshooting.
elachlan commented 2 months ago

@Olina-Zhang can your team investigate this please?

Olina-Zhang commented 2 months ago

We have an existing similar designer issue: https://github.com/microsoft/winforms-designer/issues/5796, it also has the same verbose log:

fail: Request failures: Types/GetEditor.
14:14:35:411                            Microsoft.DotNet.DesignTools.Client.DesignToolsServerException: Could not resolve type, 'System.ComponentModel.ComponentEditor, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

Not sure if they have the same root cause.