ConfigurationErrorsException: Unrecognized configuration section system.windows.forms.applicationconfigurationsection

185 Views Asked by At

I am trying to leverage the new High DPI support using .net 4.8 in a WinForms app and adding in the section below to the app.config causes a number of things to fail. AppSettings, new SQLConnection, etc..

<system.windows.forms.applicationconfigurationsection>
   <add key="DpiAwareness" value="PerMonitorV2"/>
   <add key="EnableWindowsFormsHighDpiAutoResizing" value="true"/>
</system.windows.forms.applicationconfigurationsection>

I followed the information from this page https://learn.microsoft.com/en-us/dotnet/desktop/winforms/high-dpi-support-in-windows-forms?view=netframeworkdesktop-4.8 and I am still getting the same errors. The DPI functionality works perfectly though.

**ConfigurationErrorsException: Unrecognized configuration section system.windows.forms.applicationconfigurationsection. **

I also copied what was on the page and it fails and the DPI functionality doesn't work.

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

Any ideas on what I can try? This application was initially written in .net 4.0 I believe. I migrated to .net 4.8 when I upgraded to Visual Studio 2022.

Thanks.

0

There are 0 best solutions below