*** removed unnecessary quote ***
You're encountering an issue with Windows Forms applications on high-resolution displays with scaling enabled, where the application's DPI awareness settings don't match the system settings at runtime. This often leads to blurry text and incorrect form sizing. The fact that it's specific to one project points to a configuration difference within that project.
DPI Awareness Settings in app.config or app.manifest:
Modern .NET Framework applications (starting with 4.7) and .NET (Core) use settings in the app.config file to control High DPI awareness. Older applications might use an app.manifest file.
Check app.config:Open the app.config file in your problematic project and look for a <System.Windows.Forms.ApplicationConfigurationSection> element. Within this section, there might be a <add key="DpiAwareness" value="..." /> entry.
PerMonitorV2 is the recommended setting for applications that need to adapt to different DPI settings when moved between monitors with varying scales. This is likely what you want for a 4K monitor with 200% scaling.
System means the application scales based on the primary display's DPI when it starts and doesn't adjust if moved to a different monitor. This can cause blurriness and incorrect sizing.
DPIUnaware means the application assumes 100% scaling (96 DPI) regardless of the actual display settings. Windows will then bitmap stretch the application, leading to significant blurriness.
Check app.manifest: If you don't have the ApplicationConfigurationSection in app.config or are using an older .NET Framework, check if your project has an app.manifest file. Look for a <dpiAwareness> or <dpiAware> element within the <windowsSettings> section. The value here also dictates the DPI awareness mode.
Compare with Working Projects: Examine the app.config and app.manifest files in your working projects to see how their DPI settings are configured. They likely have a setting that is more appropriate for high DPI displays.
Action to take that may help you:
If your problematic project has DPIUnaware or System set, try changing it to PerMonitorV2 in app.config (for .NET Framework 4.7+) or configure the manifest accordingly.
If the working projects have different, more appropriate settings, try copying those settings to the problematic project.
Application.SetHighDpiMode in Program.cs to understand:
In newer .NET versions, the DPI awareness can also be set programmatically at the application entry point (usually in Program.cs) using Application.SetHighDpiMode(HighDpiMode.<Mode>).
Open Program.cs and look for this line, often before Application.Run().
Compare the HighDpiMode used in the problematic project with your working projects. HighDpiMode.PerMonitorV2 is the preferred setting.
Actions continued...
Ensure the problematic project is using HighDpiMode.PerMonitorV2 if you are setting DPI awareness programmatically.
Compatibility Settings (Less Likely for a New Project Issue):
Windows compatibility settings can sometimes override application-level DPI settings. While less likely to be the sole cause for a project-specific issue unless it was manually applied, it's worth checking.
Find the executable file of your problematic application in the bin folder (either Debug or Release).
Right-click the executable and select "Properties."
Go to the "Compatibility" tab.
Click on "Change high DPI settings."
See if any "High DPI scaling override" options are checked.
Actions continued...
If any override is enabled, try disabling it and see if the issue is resolved.
AutoScaleMode Property of the Form:
The AutoScaleMode property of your forms can also influence how controls are scaled with DPI changes. The common settings are Font and Dpi.
Open the designer for your problematic form.
Select the form itself (click on the form's title bar).
In the Properties window, check the AutoScaleMode property.
Actions continued...
While Dpi is often recommended for better high DPI scaling, inconsistencies can sometimes arise. Compare this setting across your projects. If they differ, try making them consistent.
Visual Studio Designer vs. Runtime Differences:
It's important to note that the Visual Studio WinForms designer itself has had historical issues with high DPI scaling. The designer might not always accurately reflect how the form will look at runtime, especially with complex layouts or custom controls. The info bar you mentioned in Visual Studio offering to restart with 100% scaling is a testament to this. However, your issue is the reverse – it looks good in the designer but bad at runtime, which strongly points back to the application's runtime DPI configuration.
Troubleshooting Steps to help....
Focus on the Problematic Project: Concentrate your efforts on identifying differences in the DPI configuration settings within the problematic project's app.config, app.manifest, and Program.cs compared to the working projects.
Simplify for Testing: If possible, create a new, simple WinForms project targeting the same .NET version as the problematic project. Add a form with a few controls and run it on your 4K monitor. See if it exhibits the same blurry text and scaling issues. If the new project works correctly, carefully compare its default configuration files with your problematic project.
Examine Project File (.csproj): Although less common for direct DPI settings, open the .csproj file of both projects in a text editor and look for any differences related to DPI or application manifests that might be explicitly included or excluded.
By systematically checking these configuration points and comparing them between your working and non-working projects, you should be able to pinpoint the setting that is causing the incorrect runtime behavior on your high DPI display. The most likely culprit is an incorrect or missing DPI awareness setting that tells Windows how your application should handle scaling at runtime.