Differences between App.Config and Web.Config?
Asked Answered
A

2

50

when building a desktop app in wpf can you read documentation of problems and safely subsititute 'app.config' when people's answer's refer to 'web.config'?

if so are there any glaring GOTCHAS you have to look out for?

tnx

Apodictic answered 11/9, 2009 at 18:26 Comment(1)
Possible duplicate of https://mcmap.net/q/355789/-web-config-and-app-config-confusionDisciple
T
39

Read the Documentation:

Web.config and App.config

The choice of the configuration file name is determined by the hosting environment you choose for the service. If you are using IIS to host your service, use a Web.config file. If you are using any other hosting environment, use an App.config file.

In Visual Studio, the file named App.config is used to create the final configuration file. The final name actually used for the configuration depends on the assembly name. For example, an assembly named "Cohowinery.exe" has a final configuration file name of "Cohowinery.exe.config". However, you only need to modify the App.config file. Changes made to that file are automatically made to the final application configuration file at compile time.

In using an App.config, file the configuration system merges the App.config file with content of the Machine.config file when the application starts and the configuration is applied. This mechanism allows machine-wide settings to be defined in the Machine.config file. The App.config file can be used to override the settings of the Machine.config file; you can also lock in the settings in Machine.config file so that they get used. In the Web.config case, the configuration system merges the Web.config files in all directories leading up to the application directory into the configuration that gets applied.

Tannic answered 18/6, 2013 at 4:55 Comment(0)
P
35

Web.Config is used for asp.net web projects / web services.

App.Config is used for Windows Forms, Windows Services, Console Apps and WPF applications

Your question isn't providing all the information as to where the gotcha's may lie for you.

Can you give us more info on what you are trying to do in terms of these config files?

Putnam answered 11/9, 2009 at 18:30 Comment(1)
That's not completely true. I've created a WCF Service Library project and it uses an app.config rather than a web.config. I've understood that the difference resides in the app.config non final state, as opposed to the web.config final one.Cingulum

© 2022 - 2024 — McMap. All rights reserved.