Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Differences between App.Config and Web.Config?

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

like image 493
Jack McG Avatar asked Sep 11 '09 18:09

Jack McG


People also ask

What is app config?

App. Config is an XML file that is used as a configuration file for your application. In other words, you store inside it any setting that you may want to change without having to change code (and recompiling). It is often used to store connection strings.

Can we run application without web config?

Yes, you will be able to run an ASP.NET application without a WEB. CONFIG file in its root folder. If the application doesn't find a WEB. CONFIG file in its root folder, then it will take MACHINE.

What is web config?

A web. config file is a Windows file that lets you customize the way your site or a specific directory on your site behaves. For example, if you place a web. config file in your root directory, it will affect your entire site (www.coolexample.com).

How many app config file in asp.net application?

Application configuration files Executable–hosted app. These apps have two configuration files: a source configuration file, which is modified by the developer during development, and an output file that is distributed with the app.


2 Answers

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.

like image 117
CloudyMarble Avatar answered Sep 28 '22 03:09

CloudyMarble


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?

like image 36
Peter Avatar answered Sep 28 '22 02:09

Peter