none
VS2017 IDE vs. Run Time Rendering Discrepancy Because of Win10 Text Size > 100% - How Do I Add an App Manifest?

    Question

  • I have VS2017 installed on a Win10 system.  In developing a new app (the first one in several years!) I found that the IDE's rendering of forms did not match the form rendering which was occurring at debug run time (on the same system).  In particular, text which fit in a box when rendered by the IDE did not fit in the box when rendered at run time.  In researching the problem it seemed to me that it was likely because in Settings > Display under "Scale and Layout" under "Change the size of text, ..." I had a value greater than 100%.  Maybe around 115% although I no longer recall exactly what it was.  

    Of course I do not want to tell customers that they must have a value of exactly 100% if they want the app forms to be rendered properly.  The only fix I have found is this one: https://social.msdn.microsoft.com/Forums/vstudio/en-US/7b606ee7-5814-46a1-9b2d-959eccfa0c35/vbnet-blurry-application-during-runtime?forum=vbgeneral

    It says to "Add a new app manifest from the solution explorer using Add New Item".  OK, so far so good.  But then it says to make an addition to the app.config file "under <configuration>:".  But where under "<configuration>:"?  Immediately under so that it is on the same level as <configSections> ,  <startup> , and <userSettings> or within one of those sections?  

    Thanks,  Bob

    Saturday, February 9, 2019 3:41 PM

Answers

  •  Please have a look at the answer I gave in the link below.  You do not need to add an app.manifest file,  you just need to go to your application properties and on the Application tab you click the 'View Windows Settings' button.  That will open your app.manifest file.  I explain these steps to set the application to be DpiAware in the answer of that link.  However,  be sure to read the link I posted in my answer at the link below.  It seems that in windows 10 you may need to modify the app.config file.

     Bad resolution with TextRenderer


    If you say it can`t be done then i`ll try it

    • Marked as answer by eBob.com Monday, February 11, 2019 5:32 PM
    Saturday, February 9, 2019 4:59 PM
  • Hi eBob.com,

    (1) As IronRazerz mentioned, add an "app.manifest" file and make DPI-aware UnCommented.
        (I suppose you can see it at line 50 or so)
        

    (2) Make [AutoScaleMode] of Windows Form "DPI".

        

    Regards,

    Ashidacchi -- https://ssl01.rocketnet.jp/hokusosha.com/default.html

    • Marked as answer by eBob.com Monday, February 11, 2019 5:32 PM
    Saturday, February 9, 2019 11:12 PM
  •  As I mentioned in the first link,  I don't have windows 10 and can not try the new methods,  so I am not sure what the app.config file even looks like on your end.  The msdn page that I linked to in that answer says it is for applications that are targeting .net 4.7 or above,  and are running on windows 10 creators update or above.  I use Win7,  VS2015,  .Net 4.5 or 4.6 and never had to mess with the config file to do this.

     So,  unfortunately I can not really look at the config file or test it to be sure where to put the mods in the app.config file.  It sure would be nice if microsoft would put some clear to understand information and examples in their documentation about this.  I tried to find some real examples of the config file for doing this in win10 with no luck.  It must be a trial and error kind of thing.

     I read some threads in a few different forums and it seemed that some people had success by just setting the DpiAware setting in the app.manifest file,  some modified both the manifest and the config files,  others needed to also change the form's AutoScaleMode to Dpi instead of Font.  Like I said,  sure would be nice if microsoft would put some clear info and examples for this subject since it is being required more and more with newer computers and monitors.


    If you say it can`t be done then i`ll try it

    • Marked as answer by eBob.com Monday, February 11, 2019 5:31 PM
    Sunday, February 10, 2019 12:49 AM

All replies

  •  Please have a look at the answer I gave in the link below.  You do not need to add an app.manifest file,  you just need to go to your application properties and on the Application tab you click the 'View Windows Settings' button.  That will open your app.manifest file.  I explain these steps to set the application to be DpiAware in the answer of that link.  However,  be sure to read the link I posted in my answer at the link below.  It seems that in windows 10 you may need to modify the app.config file.

     Bad resolution with TextRenderer


    If you say it can`t be done then i`ll try it

    • Marked as answer by eBob.com Monday, February 11, 2019 5:32 PM
    Saturday, February 9, 2019 4:59 PM
  • Thanks very much IronRazerz.  The link you provided to the MSDN article ("High DPI support in Windows Forms" : https://docs.microsoft.com/en-us/dotnet/framework/winforms/high-dpi-support-in-windows-forms) sounds like exactly what I need and all I should need.  I'd at least like to give it a shot.  But it requires modification to the app.config file 

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

    and I don't have any idea where in the app.config file that would go. 

    Bob

    Saturday, February 9, 2019 7:36 PM
  •  If you open the (Solution Explorer) tab you should see a file in there named app.config,  double click it and it will open.


    If you say it can`t be done then i`ll try it

    Saturday, February 9, 2019 8:05 PM
  • Thanks again for your continued help.  I was able to find app.config.  But where WITHIN
    Saturday, February 9, 2019 10:05 PM
  • Thanks again for your continued help.  I was able to find app.config.  But where WITHIN

    ... (to continue) ... where WITHIN the app.config file.  I understand nothing in the app.config file so I am not able to determine the right location.

    Thanks,  Bob

    Saturday, February 9, 2019 10:06 PM
  • Hi eBob.com,

    (1) As IronRazerz mentioned, add an "app.manifest" file and make DPI-aware UnCommented.
        (I suppose you can see it at line 50 or so)
        

    (2) Make [AutoScaleMode] of Windows Form "DPI".

        

    Regards,

    Ashidacchi -- https://ssl01.rocketnet.jp/hokusosha.com/default.html

    • Marked as answer by eBob.com Monday, February 11, 2019 5:32 PM
    Saturday, February 9, 2019 11:12 PM
  •  As I mentioned in the first link,  I don't have windows 10 and can not try the new methods,  so I am not sure what the app.config file even looks like on your end.  The msdn page that I linked to in that answer says it is for applications that are targeting .net 4.7 or above,  and are running on windows 10 creators update or above.  I use Win7,  VS2015,  .Net 4.5 or 4.6 and never had to mess with the config file to do this.

     So,  unfortunately I can not really look at the config file or test it to be sure where to put the mods in the app.config file.  It sure would be nice if microsoft would put some clear to understand information and examples in their documentation about this.  I tried to find some real examples of the config file for doing this in win10 with no luck.  It must be a trial and error kind of thing.

     I read some threads in a few different forums and it seemed that some people had success by just setting the DpiAware setting in the app.manifest file,  some modified both the manifest and the config files,  others needed to also change the form's AutoScaleMode to Dpi instead of Font.  Like I said,  sure would be nice if microsoft would put some clear info and examples for this subject since it is being required more and more with newer computers and monitors.


    If you say it can`t be done then i`ll try it

    • Marked as answer by eBob.com Monday, February 11, 2019 5:31 PM
    Sunday, February 10, 2019 12:49 AM
  • Thank you very much IronRazerz and Ashidakku kokusai-sha arigatōgozaimasu. (Watashi wa nan-nen mo mae ni 2-nenkan Tōkyō ni sunde imashita. Subarashī keiken. Watashi wa mada sore o koishiku omoimasu.*)

    You have both been very helpful.  It may be awhile before I have time to experiment with this but I will let you know what worked for me.  

    Thanks very much,  Bob

    * At one time I could have written that bit of Japanese without using Google Translate but, sadly, no longer.  

    Monday, February 11, 2019 12:24 PM