title: Different and wrong size of a WinForms form on high-resolution screen in VS IDE and exe
body: <p>I am developing a C# WinForms app for .NET 4.0 in VS 2017 on my ASUS NV552 laptop with UltraHD monitor with 282ppi. To work comfortably, I set the system scale factor to 300% in my Windows 10 Pro Creators Update. When I compile and launch the project, the size of the form differs from what I see in the VS Designer and it seems, .NET stops recalculating the form size at all for big form sizes.</p>
  <p>For instance, when the form's <code>Size</code> property is set to <code>1606; 1284</code> in the VS property browser, the result size of the form on the screen displayed from the exe is 421x285. However, when I resize the form in the Designer say to 1943x1284, I see the same form of 421x285 in the exe!</p>
  <p>Moreover, it seems, for smaller sizes I even see the result form with improper proportions of width and height.</p>
  <p>If it helps somehow, below are the corresponding auto-scale settings for this form in the .designer.cs file when <code>Size</code> equals <code>1606; 1284</code>:</p>
  <pre class="lang-cs prettyprint-override"><code>this.AutoScaleDimensions = new System.Drawing.SizeF(19F, 37F);
  this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  this.ClientSize = new System.Drawing.Size(1570, 1181);
  </code></pre>
  <p>I do understand that by default VS 2017 produces DPI-unaware exe applications, and that's OK if the form size is reduced in pixels when it is displayed from the exe (as if it were developed for 96ppi). Microsoft solved this problem with the release of .NET Framework 4.7 - now we can make our WinForms forms DPI-aware using the following setting in app.config (according to <a href="https://docs.microsoft.com/en-us/dotnet/framework/winforms/high-dpi-support-in-windows-forms" rel="nofollow noreferrer">High DPI support in Windows Forms</a>):</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;configuration&gt;
      &lt;System.Windows.Forms.ApplicationConfigurationSection&gt;
          &lt;add key=&quot;DpiAwareness&quot; value=&quot;PerMonitorV2&quot; /&gt;
      &lt;/System.Windows.Forms.ApplicationConfigurationSection&gt;
  &lt;/configuration&gt;
  </code></pre>
  <p>But I need to solve the problem for old legacy DPI-unaware WinForms apps. Is there a solution?</p>
  <p>Please, don't write useless comments containing phrases like &quot;WinForms is dead&quot; and &quot;switch to WPF&quot;. Write only if you have ideas how to improve the described behavior in WinForms projects.</p>