dotnet / winforms

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

Designer not loading. BindingSource + PerMonitorV2 #8625

Closed kirsan31 closed 1 year ago

kirsan31 commented 1 year ago

Environment

Microsoft Visual Studio Community 2022 Version 17.4.4 VisualStudio.17.Release/17.4.4+33213.308 Microsoft .NET Framework Version 4.8.09032

.NET version

.Net7 .Net6

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

Yes in .Net framework

Issue description

Designer not loading with errors. If you comment out this line in DesignerLoadBug.csproj:

<ApplicationHighDpiMode>PerMonitorV2</ApplicationHighDpiMode>

OR these lines in Form1.Designer.cs:

this.form1BindingSource = new System.Windows.Forms.BindingSource(this.components);
((System.ComponentModel.ISupportInitialize)(this.form1BindingSource)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.form1BindingSource)).EndInit();

designer will load normally.

Steps to reproduce

Open test project, open Form1 in the designer. DesignerLoadBug.zip

Diagnostics

warn: DPI mode PerMonitorV2 specified in the project is not compatible with Visual Studio process DPI mode SystemAware. Winforms designer will have DPI mode SystemAware 
warn: DPI mode PerMonitorV2 specified in the project is not compatible with Visual Studio process DPI mode SystemAware. Winforms designer will have DPI mode SystemAware 
fail: Request failures: Sessions/EndLoad.
                        Microsoft.DotNet.DesignTools.Client.DesignToolsServerException: Failed to set Win32 parent window of the Control.
dreddy-work commented 1 year ago

possibly related #8519.

dreddy-work commented 1 year ago

@kirsan31 , linked PR is being tested. I am hoping to merge that this week and I will check if this scenario is one of those cases and update it here.

kirsan31 commented 1 year ago

Oh sorry, my bad - didn't search before posting new issue 😔 Was 100% shure that this is designer problem...

dreddy-work commented 1 year ago

Oh sorry, my bad - didn't search before posting new issue 😔

np. I am also looking at VS specific solution that we can service. I will link that as well when it is ready.

merriemcgaw commented 1 year ago

Targeting 8.0 and up is working. But VS solution has a few SystemAware instances to read the Project File's awareness.

merriemcgaw commented 1 year ago

Can you close this when the PR is merged @dreddy-work

dreddy-work commented 1 year ago

Following PR shoudl help for .NET 7.0 and below target frameworks. https://github.com/microsoft/winforms-designer/pull/5081

Olina-Zhang commented 1 year ago

Verified this issue in the latest .Net 8.0 build: 8.0.100-preview.4.23206.10, it is not reproduced. But for 7.0, it is reproduced so far.

kirsan31 commented 1 year ago

Still an issue with 7.0 and 17.6.0 :(

Olina-Zhang commented 1 year ago

Still an issue with 7.0 and 17.6.0 :(

It is in 17.7 Preview 1 build for .Net 7.0 and below.

Philip-Wang01 commented 1 year ago

Verified this on .NET 8.0 test pass build: 8.0.100-preview.5.23276.4, issue was fixed.