In .NET, after building a project, why do I sometimes have an app.config and other times a binaryname.dll.config file?
My App. config setting now automatically get included in the DLL.
You cannot use multiple configuration files (i.e. one per library project) without coding.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With