Closed Olina-Zhang closed 1 year ago
I can open it fine with latest WinForms binaries in .NET 8.0. By any chance do you have registry key set for Devenv process to start in a different DPiAwareness? Otherwise, simple Winforms app setting PermonV2 is working fine for me.
@Olina-Zhang , can you check this on a different machine and see if you can repro it?
@Olina-Zhang , can you check this on a different machine and see if you can repro it?
Yes, we have laptop and Azure VMs verified it, all can repro.
I can open it fine with latest WinForms binaries in .NET 8.0.
@dreddy-work, Did you use the app I provided in issue?
I can open it fine with latest WinForms binaries in .NET 8.0.
@dreddy-work, Did you use the app I provided in issue?
Yes. I used the app provided here too. Can you try create a simple winforms app with target to 8.0 and see if everything is okay?
Can you try create a simple winforms app with target to 8.0 and see if everything is okay?
That works fine.
That works fine.
So, what is not working here. What is so specific about this test app? Do you have any other winforms apps that are failing to load when set PermOnitorV2 mode?
@dreddy-work, the form designer just has some our common controls, for example: toolStrip with toolStripbutton added. Could you please use that app I provided again? By default, it has SystemAware setting, you need to change it to PerMonitorV2, then re-build app to open form designer. I also use a toolstrip as an example:
Verified this on .NET latest build: 8.0.100-preview.3.23165.21, issue was fixed, on 100%DPI or 250%DPI environment, after setting ApplicationHighDpiMode to PerMonitorV2, the form designer loading successfully. The gif as below:
Verified this on .NET 8.0 Preview 3.0 TP build: 8.0.100-preview.3.23178.7, issue was fixed, the form designer loading successfully. Gif same as above.
.NET version
8.0.100-alpha.1.22556.1
Did it work in .NET Framework?
Yes
Did it work in any of the earlier releases of .NET Core or .NET 5+?
No, it also repro in .Net 7.0 and .Net 6.0 SDK builds
Issue description
On 100%DPI or High DPI environment, after setting ApplicationHighDpiMode to PerMonitorV2, form designer failed to load:
Here is the logs in Output window: [00:53:41.632681] 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 [00:53:47.223103] fail: Request failures: Sessions/EndLoad. Microsoft.DotNet.DesignTools.Client.DesignToolsServerException: Failed to set Win32 parent window of the Control.
Call stack: ** Exception Text ** System.ComponentModel.Win32Exception (5023): Failed to set Win32 parent window of the Control. at System.Windows.Forms.Control.SetParentHandle(HWND value) in C:\Users\xxx\Documents\Winforms\src\System.Windows.Forms\src\System\Windows\Forms\Control.cs:line 11054 at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) in C:\Users\xxx\Documents\Winforms\src\System.Windows.Forms\src\System\Windows\Forms\Control.cs:line 5082 at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) in C:\Users\xxx\Documents\Winforms\src\System.Windows.Forms\src\System\Windows\Forms\Control.cs:line 5085 at System.Windows.Forms.Control.CreateControl() in C:\Users\xxx\Documents\Winforms\src\System.Windows.Forms\src\System\Windows\Forms\Control.cs:line 5028 at System.Windows.Forms.Control.OnVisibleChanged(EventArgs e) in C:\Users\xxx\Documents\Winforms\src\System.Windows.Forms\src\System\Windows\Forms\Control.cs:line 7810 at System.Windows.Forms.Control.OnParentVisibleChanged(EventArgs e) in C:\Users\xxx\Documents\Winforms\src\System.Windows.Forms\src\System\Windows\Forms\Control.cs:line 7707 at System.Windows.Forms.Control.OnVisibleChanged(EventArgs e) in C:\Users\xxx\Documents\Winforms\src\System.Windows.Forms\src\System\Windows\Forms\Control.cs:line 7830 at System.Windows.Forms.Control.WmShowWindow(Message& m) in C:\Users\xxx\Documents\Winforms\src\System.Windows.Forms\src\System\Windows\Forms\Control.cs:line 12974 at System.Windows.Forms.Control.WndProc(Message& m) in C:\Users\xxx\Documents\Winforms\src\System.Windows.Forms\src\System\Windows\Forms\Control.cs:line 13382 at Microsoft.DotNet.DesignTools.Frame.DesignerWindowFrame.WndProc(Message& m) in C:\Users\xxx\source\repos\winforms-designer\src\Microsoft.DotNet.DesignTools.Server\Frame\DesignerWindowFrame.cs:line 123 at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) in C:\Users\xxx\Documents\Winforms\src\System.Windows.Forms\src\System\Windows\Forms\Control.ControlNativeWindow.cs:line 114 at System.Windows.Forms.NativeWindow.Callback(HWND hWnd, WM msg, WPARAM wparam, LPARAM lparam) in C:\Users\xxx\Documents\Winforms\src\System.Windows.Forms\src\System\Windows\Forms\NativeWindow.cs:line 375
Steps to reproduce