In my project I have functionality that is being used as a web application and as a console application (to be started from the task scheduler). To do that I put the common code in a DLL that is being used by both the web application and the console application. This works fine.
However, the console and web applications now have an App.config and Web.config that are mostly the same. Is it possible to put this configuration in the DLL as well and make it available to both applications?
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.
My App. config setting now automatically get included in the DLL.
Yes, you can and should put the common configuration settings in the config file for your DLL. Just add an app.config file to the DLL project, and make sure you read the configuration settings from inside the DLL. When deployed, your config file needs to have the name "MyDLL.dll.config" (assuming your DLL is named "MyDLL.dll") and be in the same folder as the DLL.
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