Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Putting configuration information in a DLL

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?

like image 920
jan.vdbergh Avatar asked Oct 02 '08 11:10

jan.vdbergh


People also ask

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.

Is app config included in DLL?

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


1 Answers

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.

like image 189
MusiGenesis Avatar answered Oct 22 '22 22:10

MusiGenesis