Conflict in official documents

StewartBW 1,905 Reputation points
2025-06-16T19:36:50.1533333+00:00

Hi

Here mentioned:

https://learn.microsoft.com/en-us/dotnet/desktop/winforms/high-dpi-support-in-windows-forms?view=netframeworkdesktop-4.8

In previous versions of the .NET Framework, you used the manifest to add high DPI support. This approach is no longer recommended, since it overrides settings defined on the app.config file.

But the latest version of Windows 11 SDK : Windows App Certification Kit analyze report:

High-DPI support WARNING DPIAwarenessValidation Warning: The DPI-awareness validation test detected following Warnings: File VFS\ProgramFilesX64\blah.exe neither has PerMonitorV2 manifested in the manifest nor calls into DPI Awareness APIs for ex: user32!SetProcessDpiAwarenessContext or user32!SetThreadDpiAwarenessContext. The app blah is not DPI Aware.

My msix includes app.config with PerMonitorV2 already! However, I'm not sure which method to use for WinForms / .Net Fw 4.8 apps, manifest or app.config!

Also, my VB.NET apps has enabled application framework and I have no access to the sub main, how to run:

Application.EnableVisualStyles()

Application.SetCompatibleTextRenderingDefault(false)

required for that?

<EnableVisualStyles>true</EnableVisualStyles> is already there in Application.myapp

Thanks :)

Developer technologies | VB
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Varsha Dundigalla(INFOSYS LIMITED) 3,725 Reputation points Microsoft External Staff
    2025-11-14T14:39:50.67+00:00

    Thank you for reaching out.

    There seems to be a conflict between .NET Framework guidance and Windows App Certification Kit (WACK) warnings for High-DPI support in WinForms apps.

    • For .NET Framework 4.8 WinForms, DPI awareness should be declared in app.config using <System.Windows.Forms.ApplicationConfigurationSection> with DpiAwareness="PerMonitorV2". This is the recommended approach because it integrates with WinForms DPI scaling.
    • WACK checks the manifest and API calls (e.g., SetProcessDpiAwarenessContext) at OS level. It does not parse app.config, so even if your app.config is correct, WACK may still warn.\ Solution: Add DPI awareness to the manifest for certification purposes. This won’t break WinForms behavior but satisfies WACK.

    VB.NET Application Framework:\ If <EnableVisualStyles>true</EnableVisualStyles> is set in Application.myapp, the framework automatically calls:

    Application``.EnableVisualStyles()

    You don’t need Sub Main unless you want custom startup logic. If you do, disable “Enable application framework” in project settings and create your own Sub Main.

    Sample app.config snippet:

    <configuration>
      <runtime>
        <System.Windows.Forms.ApplicationConfigurationSection
          DpiAwareness="PerMonitorV2" />
      </runtime>
    

    Sample manifest snippet for WACK compliance:

    <application xmlns="urn:schemas-microsoft-com:asm.v3">
      <windowsSettings>
        <dpiAware>true/PM</dpiAware>
        <dpiAwareness>PerMonitorV2</dpiAwareness>
      </windowsSettings>
    

    This way, you keep app.config for WinForms DPI handling and add manifest entries for WACK validation.

    Please let us know if you require any further assistance, we’re happy to help.

    If you found this information useful, kindly mark this as "Accept Answer".


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.