Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.Net app.config in library project

I have a console application project and library project (dll) in one solution. The library project has app.config file where I store a connection string to database. The console application references this dll.

When I compile the console application and deploy it with the library I am not able to access the app.config file that belongs the dll when I need to change the connection string after the application is deployed.

This are the files that I see, but not .config file:

  • library.dll
  • library.pdb
  • console.application
  • console.exe
  • console.exe.manifest
  • console.pdb
  • console.vshost.application
  • console.vshest.exe

Where did I go wrong?

like image 701
psabela Avatar asked Jan 22 '23 23:01

psabela


1 Answers

By default, there is only 1 ".config" file for a running application. It is the ".config" file associated with the EXE that started the program. You should probably copy the config values from the DLL's config file into the console app's config file. If you really want to keep them separate then you can't use the default ConfigurationSettings.AppSettings dictionary. See this question for more info.

like image 124
David Avatar answered Jan 25 '23 13:01

David