Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do I sometimes have an app.config and other times a binaryname.dll.config file?

In .NET, after building a project, why do I sometimes have an app.config and other times a binaryname.dll.config file?

like image 273
Matt Avatar asked Mar 15 '12 23:03

Matt


People also ask

Is app config included in DLL?

My App. config setting now automatically get included in the DLL.

Can we have multiple app config files?

You cannot use multiple configuration files (i.e. one per library project) without coding.

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.

Can DLL have config file?

Using configuration files in DLL is not trivial, but is very simple. Using configuration files in DLL is not trivial. To accomplish this, we must follow these steps: Add a reference to System.


1 Answers

You see it as app.config file during development (in Visual Studio). When deployed (as well as in your bin directory), app.config becomes binaryname.dll/exe.config file (automatically renamed by Visual Studio).

As for the exact reason...there is a good reason not to have it as app.config...for example, if you deploy several applications in the same directory, you would be able to have only one app.config...so there is a good reason to name it binaryname.dll.config.

So the real question is: why is it named app.config and not binaryname.dll.config in the first place?

One of the reasons I can think of is that you can always change your binary output name in project options (so compiler generates .exe file with a name different than your project name), and config file will be copied to correspond to that binary output name. Having it named app.config in the solution is better because you always copy the same file name to some destination file name, without a need to rename that file in solution (which is good especially when that file is under source control). There might be some other reason as well.

like image 128
Aleksandar Vucetic Avatar answered Oct 20 '22 01:10

Aleksandar Vucetic