1

I have a solution with the following setup:

X amount of class library projects Y amount of console application projects

Each of these projects may have 0 or more configuration parameters.

Now, I'd like to have only one App.config for user to specify settings and that App.config will only contain parameters of all the reference projects of the console application project to be run.

I've tried giving each project a Settings file and then linking them to the console applications according to their dependencies but that didn't work.

I've also tried just lumping all the configurations together in one class library project and have each console application link to that app.config (or settings file). But that also didn't work (i.e. changes of the app.config or the settings file in the class library will not update the .config of the executable)

Is what I am trying to do possible?

Filburt
  • 17,626
  • 12
  • 64
  • 115
user1836155
  • 858
  • 14
  • 29
  • http://stackoverflow.com/questions/1361913/single-app-config-multi-project-c-sharp?rq=1 - Check this – Attila Mar 06 '14 at 22:23
  • Or this: http://stackoverflow.com/questions/4738/using-configurationmanager-to-load-config-from-an-arbitrary-location?lq=1 – Attila Mar 06 '14 at 22:24

1 Answers1

0

Yes, it is possible. You just need to open the app file. Follow the next example:

ConfigurationManager.OpenExeConfiguration("C:\Test\SomeProject.dll");
XmlNode loggingConfigNode = ConfigurationManager.GetSection("log4net") as XmlNode;

I guess that you will have to open each setting file in order to use the settings, or you will have to consolidate all the settings in a single app.config and then your applications can access the file by open it.

Franml32
  • 36
  • 2
  • 1
    Hmm... Is there an alternative to using filepaths? Seems like most if not all of these solutions require that. – user1836155 Mar 12 '14 at 13:41