Open OwnageIsMagic opened 1 week ago
So you followed the warning and commented out dpiAwareness
from the manifest and configured the dpi settings via Application.SetHighDpiMode
API or ApplicationHighDpiMode
project property?
Do you have a copy of your program.cs?
@elachlan actually the other way around. App was looking strange in aot mode, so I tried to enable dpi awareness via manifest, it worked, but produced warning.
Program.cs is default one generated by dotnet new winforms
.
I verified that ApplicationConfiguration.Initialize();
contains global::System.Windows.Forms.Application.SetHighDpiMode(HighDpiMode.SystemAware);
All code here is the full repro.
@Olina-Zhang can your team please verify?
@Olina-Zhang can your team please verify?
We can repro it in the latest .NET 9.0 Preview6 SDK build with PublishAot
deployment.
Is it related to this? https://github.com/dotnet/winforms/issues/9911#issuecomment-1719050890
@chrarnoldus dpiAware=true
is equivalent to dpiAwareness=system
and SystemAware
is default for netcore winforms and wpf (as mentioned in comment)
So using system
is ok.
And yes, it's probably related to initialization order.
If you don't do this via the project settings, but have the code manually added in Program.cs to control HighDPI settings and other settings, does that then change anything?
Also not, that Trimming/AOTing WinForms Apps is not supported at this time, but we're working on it.
@KlausLoeffelmann adding this doesn't resolve the issue.
static Program()
{
Application.SetHighDpiMode(HighDpiMode.SystemAware);
}
[System.Runtime.CompilerServices.ModuleInitializer]
internal static void M1()
{
Application.SetHighDpiMode(HighDpiMode.SystemAware);
}
Huh, "supported" winforms trimming looks like this error NETSDK1175: Windows Forms is not supported or recommended with trimming enabled. Please go to https://aka.ms/dotnet-illink/windows-forms for more details.
.😉
.NET version
.NET SDK: Version: 9.0.100-preview.5.24307.3 Commit: 35b2c21ea6 Workload version: 9.0.100-manifests.6407b7e4 MSBuild version: 17.11.0-preview-24279-02+b963c24ef
Runtime Environment: OS Name: Windows OS Version: 10.0.19045 OS Platform: Windows RID: win-x64
Microsoft.WindowsDesktop.App 9.0.0-preview.5.24306.8
Did it work in any of the earlier releases of .NET Core or .NET 5+?
No response
Issue description
dotnet publish
dotnet run
or publish with<dpiAware />
in manifestCSC : warning WFAC010: Remove high DPI settings from C:\Source\ttt\app.manifest and configure via Application.SetHighDpiMode API or 'ApplicationHighDpiMode' project property
Display settingsSteps to reproduce
mkdir ttt && cd ttt && dotnet new winforms
Form1.csttt.csproj
app.manifest