Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add a setting to app.config or will adding the setting to *.exe.config be suffice?

A recent article: https://blogs.msdn.microsoft.com/dotnet/2017/04/05/announcing-the-net-framework-4-7/ announces a possible fix for intermittent problems with touch screen support. As I read the document, one only needs to change the app.config file. See the line:

"You can opt-into the new touch implementation with the following app.config entry.

    <runtime>
            <AppContextSwitchOverrides value="Switch.System.Windows.Input.Stylus.EnablePointerSupport=true"/>

</runtime>

under section:

WPF Touch/Stylus support for Windows 10

My question is: Can I just make the change in Myapp.exe.config or must I actually make it in app.config? Perhaps the question could be: Is the app.config info used at compile time or just translated into myapp.exe.config?

Further, I'd like to know if it's ok to leave:

<startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
  </startup>

The documentation just mentions adding EnablePointerSupport and makes no mention of changing the Version in the config file. I did in fact download the .NET Framework 4.7 and install, but have not changed the Version in the config file. Do I need to?

Thanks.

like image 563
Dave Avatar asked Oct 16 '22 10:10

Dave


1 Answers

Can I just make the change in Myapp.exe.config or must I actually make it in app.config?

If your EXE is deployed you can change the App.Exe.Config, restart the application and the new config settings will be used. If you do this for an ASP.Net application (ie. change the web.config) it will cause the App Pool in IIS to be recycled and new web.config settings to be used.

Obviously add any changes to the actual App.Config so next time you compile its added automatically to the output App.Exe.Config.

You will have some more questions about this and its all documented here, do go through this its a good read:

https://learn.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-configure-an-app-to-support-net-framework-4-or-4-5


The documentation just mentions adding EnablePointerSupport and makes no mention of changing the Version in the config file. I did in fact download the .NET Framework 4.7 and install, but have not changed the Version in the config file. Do I need to?

Unless you're using .Net 4.7 specific features you can leave the version as .Net 4.5.

<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>

In this case, the article specifically states its a bug fix in .Net 4.7. So you will need to use 4.7.

To change this you edit the Project's Build tab properties (or manually in the config file).

<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7"/>

Here is a reference to the .Net Frameworks vs SKU's: https://learn.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/startup/supportedruntime-element


If app.config is used at compile time for anything other than producing the Myapp.exe.config file.

  • You're right it's used at Compile time to generate the App.Exe.Config.

  • Many people store configuration settings in config files, so an App.Exe.Config can be edited at run-time as well. At the end of the day its simply an XML file.

  • Also note you can have Transforms on your App.Configs for different environments at design-time:

enter image description here

like image 199
Jeremy Thompson Avatar answered Oct 20 '22 17:10

Jeremy Thompson