Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Common app.config for multiple applications

Tags:

c#

I have several C# console applications, which need to have the same set of settings. I want to avoid duplicity and avoid separate app.config for each application.

Is there any way to read a common app.config file (say common.config) for applications (app1.exe, app2.exe).

like image 791
Akshay J Avatar asked Mar 03 '13 02:03

Akshay J


People also ask

Is app config the same as web config?

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.

Can we add app config file in class library?

You generally should not add an app. config file to a class library project; it won't be used without some painful bending and twisting on your part. It doesn't hurt the library project at all - it just won't do anything at all.

When should I use 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.


1 Answers

Create one file called app.config. Put it in some place outside of your projects' directories, like up in the solution directory. Add it to your projects as a linked item with a relative path to the file. Set the right build action for this item (application configuration) in each project.

Now when each project builds, the file will be copied to the project's output dir with the right name.

like image 72
Ran Avatar answered Nov 03 '22 01:11

Ran