应用程序设置中的 DPIAware 和 "Enable application framework"

DPIAware and "Enable application framework" at Application Settings

我想在我们的 VB.net WinForms 应用程序中启用 dpi 感知。 所以我将下面的代码放入 app.config 文件中。 但是我们的项目没有选中复选框"enable application framework"。 我们的应用程序以一个共享的 sub main 和 .show() 开始。 当复选框未选中时,我无法启用 dpiAwareness! (从 19 年 4 月开始,您可以在任务管理器中看到 dpi 模式)app.config 设置被忽略了?!我不知道。

在测试项目中,没有问题。在那里我可以选中该框并且 app.config 起作用或者我不选中它并且可以在运行时通过 api 调用更改 dpi 模式。

</system.diagnostics>
<startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>

   <System.Windows.Forms.ApplicationConfigurationSection>
  <add key="DpiAwareness" value="PerMonitorV2" />

app.config 中的 dpi 设置在没有 "enable application framework" 复选框的情况下无法工作。

像 TnTinMn 所说的那样启用 Win 版本:

If you want use the app.config file to declare DPI awareness for .Net 4.7 and above, you also have to modify the app.manifest file (Project Properties->Application->View Window Settings button) and declare the program to be Win 10 compatible. See: Configuring your Windows Forms app for high DPI support. If using the app.config method, do not set the dpi level in the app.manifest file as that will override the app.config settings.

在我们获取新生成的 mainfest 文件并添加多年来我们需要的设置之前。我们在项目设置中将应用程序启动为“启用应用程序框架”。然后我们要把共享的主代码移到主窗体中。我认为这应该可以完成工作。非常感谢。