dotnet / winforms

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

Designer failed to load immidiately after open project #7193

Closed kant2002 closed 2 years ago

kant2002 commented 2 years ago

Environment

17.3.0 Preview 1.0

.NET version

.NET 7.0

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

No response

Issue description

I open project and almost immidiately open MainForm in the designer. It sits in the loading process. Log below.

[15:46:46.704698] info: Creating VsDesignerLoader
[15:46:46.712663] info: [Thread 1] Creating design-time ITypeResolutionService.
[15:46:46.721664] info: Start processing enqueued assemblies
[15:46:46.721664] trce: Loaded Microsoft.WinForms.DesignTools.Protocol in 00:00:00.0000106 [thread 94]
[15:46:46.721664] trce: Processed 'Microsoft.WinForms.DesignTools.Protocol' in 00:00:00.0000787
[15:46:46.723681] info: Added 'Microsoft.WinForms.DesignTools.Protocol'
[15:46:46.723681] trce: Loaded Microsoft.WinForms.DesignTools.Client in 00:00:00.0000067 [thread 94]
[15:46:46.723681] trce: Processed 'Microsoft.WinForms.DesignTools.Client' in 00:00:00.0000310
[15:46:46.725670] info: Added 'Microsoft.WinForms.DesignTools.Client'
[15:46:46.794664] info: [Thread 69] Launching server...
[15:46:47.662390] info: Shadow cache base directory: C:\Users\kant\AppData\Local\Microsoft\VisualStudio\17.0_845e2fc7\WinFormsDesigner
[15:46:47.662390] info: [SampleWindowsForms]: Preparing shadow cache folder
[15:46:47.662390] info: [SampleWindowsForms]: NetCoreServerLayout - Platform: AnyCPU, Corrected PlatformName: x64
[15:46:47.662390] info: [SampleWindowsForms]: Copying design tools server common files from: 'c:\program files\microsoft visual studio\2022\preview\common7\ide\commonextensions\microsoft\windows.forms\DesignToolsServer\Common'
[15:46:47.744390] info: [SampleWindowsForms]: Copying design tool server platform-specific files from: 'c:\program files\microsoft visual studio\2022\preview\common7\ide\commonextensions\microsoft\windows.forms\DesignToolsServer\x64'
[15:46:47.745389] info: [SampleWindowsForms]: Copying project output file: 'D:\d\github\WinFormsComInterop\samples\SampleWindowsForms\bin\Debug\net7.0-windows\SampleWindowsForms.dll'
[15:46:47.761388] info: [SampleWindowsForms]: Copying 'D:\d\github\WinFormsComInterop\samples\SampleWindowsForms\obj\Debug\net7.0-windows\SampleWindowsForms.designer.deps.json' to 'DesignToolsServer.deps.json'
[15:46:47.762388] info: [SampleWindowsForms]: Copying 'D:\d\github\WinFormsComInterop\samples\SampleWindowsForms\obj\Debug\net7.0-windows\SampleWindowsForms.designer.runtimeconfig.json' to 'DesignToolsServer.runtimeconfig.json'
[15:46:47.763389] info: [SampleWindowsForms]: Copying project reference: 'D:\d\github\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\net7.0\System.Windows.Forms.dll'
[15:46:47.766389] info: [SampleWindowsForms]: Copying project reference: 'D:\d\github\dotnet\winforms\artifacts\bin\System.Windows.Forms.Primitives\Debug\net7.0\System.Windows.Forms.Primitives.dll'
[15:46:47.767390] info: [SampleWindowsForms]: Copying project reference: 'D:\d\github\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\net7.0\Accessibility.dll'
[15:46:47.768389] info: [SampleWindowsForms]: Copying project reference: 'D:\d\github\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\net7.0\cs\System.Windows.Forms.resources.dll'
[15:46:47.769389] info: [SampleWindowsForms]: Copying project reference: 'D:\d\github\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\net7.0\de\System.Windows.Forms.resources.dll'
[15:46:47.769389] info: [SampleWindowsForms]: Copying project reference: 'D:\d\github\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\net7.0\es\System.Windows.Forms.resources.dll'
[15:46:47.770389] info: [SampleWindowsForms]: Copying project reference: 'D:\d\github\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\net7.0\fr\System.Windows.Forms.resources.dll'
[15:46:47.771389] info: [SampleWindowsForms]: Copying project reference: 'D:\d\github\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\net7.0\it\System.Windows.Forms.resources.dll'
[15:46:47.771389] info: [SampleWindowsForms]: Copying project reference: 'D:\d\github\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\net7.0\ja\System.Windows.Forms.resources.dll'
[15:46:47.772389] info: [SampleWindowsForms]: Copying project reference: 'D:\d\github\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\net7.0\ko\System.Windows.Forms.resources.dll'
[15:46:47.773390] info: [SampleWindowsForms]: Copying project reference: 'D:\d\github\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\net7.0\pl\System.Windows.Forms.resources.dll'
[15:46:47.774389] info: [SampleWindowsForms]: Copying project reference: 'D:\d\github\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\net7.0\pt-BR\System.Windows.Forms.resources.dll'
[15:46:47.775389] info: [SampleWindowsForms]: Copying project reference: 'D:\d\github\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\net7.0\ru\System.Windows.Forms.resources.dll'
[15:46:47.775389] info: [SampleWindowsForms]: Copying project reference: 'D:\d\github\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\net7.0\tr\System.Windows.Forms.resources.dll'
[15:46:47.776389] info: [SampleWindowsForms]: Copying project reference: 'D:\d\github\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\net7.0\zh-Hans\System.Windows.Forms.resources.dll'
[15:46:47.776389] info: [SampleWindowsForms]: Copying project reference: 'D:\d\github\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\net7.0\zh-Hant\System.Windows.Forms.resources.dll'
[15:46:47.777388] info: [SampleWindowsForms]: Copying project reference: 'D:\d\github\dotnet\winforms\artifacts\bin\System.Windows.Forms.Primitives\Debug\net7.0\cs\System.Windows.Forms.Primitives.resources.dll'
[15:46:47.778389] info: [SampleWindowsForms]: Copying project reference: 'D:\d\github\dotnet\winforms\artifacts\bin\System.Windows.Forms.Primitives\Debug\net7.0\de\System.Windows.Forms.Primitives.resources.dll'
[15:46:47.778389] info: [SampleWindowsForms]: Copying project reference: 'D:\d\github\dotnet\winforms\artifacts\bin\System.Windows.Forms.Primitives\Debug\net7.0\es\System.Windows.Forms.Primitives.resources.dll'
[15:46:47.779389] info: [SampleWindowsForms]: Copying project reference: 'D:\d\github\dotnet\winforms\artifacts\bin\System.Windows.Forms.Primitives\Debug\net7.0\fr\System.Windows.Forms.Primitives.resources.dll'
[15:46:47.779389] info: [SampleWindowsForms]: Copying project reference: 'D:\d\github\dotnet\winforms\artifacts\bin\System.Windows.Forms.Primitives\Debug\net7.0\it\System.Windows.Forms.Primitives.resources.dll'
[15:46:47.779389] info: [SampleWindowsForms]: Copying project reference: 'D:\d\github\dotnet\winforms\artifacts\bin\System.Windows.Forms.Primitives\Debug\net7.0\ja\System.Windows.Forms.Primitives.resources.dll'
[15:46:47.780389] info: [SampleWindowsForms]: Copying project reference: 'D:\d\github\dotnet\winforms\artifacts\bin\System.Windows.Forms.Primitives\Debug\net7.0\ko\System.Windows.Forms.Primitives.resources.dll'
[15:46:47.781389] info: [SampleWindowsForms]: Copying project reference: 'D:\d\github\dotnet\winforms\artifacts\bin\System.Windows.Forms.Primitives\Debug\net7.0\pl\System.Windows.Forms.Primitives.resources.dll'
[15:46:47.781389] info: [SampleWindowsForms]: Copying project reference: 'D:\d\github\dotnet\winforms\artifacts\bin\System.Windows.Forms.Primitives\Debug\net7.0\pt-BR\System.Windows.Forms.Primitives.resources.dll'
[15:46:47.782389] info: [SampleWindowsForms]: Copying project reference: 'D:\d\github\dotnet\winforms\artifacts\bin\System.Windows.Forms.Primitives\Debug\net7.0\ru\System.Windows.Forms.Primitives.resources.dll'
[15:46:47.782389] info: [SampleWindowsForms]: Copying project reference: 'D:\d\github\dotnet\winforms\artifacts\bin\System.Windows.Forms.Primitives\Debug\net7.0\tr\System.Windows.Forms.Primitives.resources.dll'
[15:46:47.783388] info: [SampleWindowsForms]: Copying project reference: 'D:\d\github\dotnet\winforms\artifacts\bin\System.Windows.Forms.Primitives\Debug\net7.0\zh-Hans\System.Windows.Forms.Primitives.resources.dll'
[15:46:47.783388] info: [SampleWindowsForms]: Copying project reference: 'D:\d\github\dotnet\winforms\artifacts\bin\System.Windows.Forms.Primitives\Debug\net7.0\zh-Hant\System.Windows.Forms.Primitives.resources.dll'
[15:46:47.957389] info: [SampleWindowsForms]: Launching design tools server process...
[15:46:48.427389] info: [SampleWindowsForms]: Unhandled exception. System.TypeInitializationException: The type initializer for 'Microsoft.VisualStudio.WinForms.Server.WinFormsDesignTimeAssemblies' threw an exception.
[15:46:48.427389] info: [SampleWindowsForms]:  ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.
[15:46:48.427389] info: [SampleWindowsForms]: File name: 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
[15:46:48.427389] info: [SampleWindowsForms]:    at Microsoft.VisualStudio.WinForms.Server.WinFormsDesignTimeAssemblies..cctor()
[15:46:48.427389] info: [SampleWindowsForms]:    --- End of inner exception stack trace ---
[15:46:48.427389] info: [SampleWindowsForms]:    at Microsoft.VisualStudio.WinForms.Server.WinFormsDesignTimeAssemblies.get_All()
[15:46:48.427389] info: [SampleWindowsForms]:    at DesignToolsServerX64.Program.Main(String[] args)
[15:48:47.977671] fail: [SampleWindowsForms]: Timed out while connecting to named pipe: DesignToolsServer.46701630-8cdf-4b8a-8f93-56fc135167b9

Steps to reproduce

I open https://github.com/kant2002/WinFormsComInterop project Change inside Directory.Build.props UseNet7 to True WinFormsRepoRoot to path to locally build WinForms.

Diagnostics

No response

RussKie commented 2 years ago

[15:46:48.427389] info: [SampleWindowsForms]: Unhandled exception. System.TypeInitializationException: The type initializer for 'Microsoft.VisualStudio.WinForms.Server.WinFormsDesignTimeAssemblies' threw an exception. [15:46:48.427389] info: [SampleWindowsForms]: ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified. [15:46:48.427389] info: [SampleWindowsForms]: File name: 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

Are you referencing .NET Framework in a .NET project?

kant2002 commented 2 years ago

No, I do not. And I do not even have Net Frmaeowkr TFM anywhere

kant2002 commented 2 years ago

I think this is the same for canary builds so https://github.com/dotnet/winforms/issues/7182#issuecomment-1132362956 applies

RussKie commented 2 years ago

Yes, I very much suspect so. You're trying to load a Windows Forms project in the designer that's using the globally installed .NET Windows Desktop SDK, and the project is referencing the canary bits of the Windows Desktop SDK from another place...

kant2002 commented 2 years ago

Not sure how complicated it would be, but if Designer just log message if detect System.Windows.forms.dll inside bin folder. At least that reduce noise which I can make in the future (and any contributor)

RussKie commented 2 years ago

Then we'd have to know the content of the Windows Desktop SDK so we can match any file from it... And what if someone (because why not?) decides to name their assembly System.Windows.Forms.dll? Unless the dll has the same identity, it shouldn't really be a problem.... Though I'm not 100% sure :)