P H
P H

Reputation: 963

common config file

I have got 4 .net console applications which carry out different tasks. These 4 applications share some common configuration that I pass through app.config file. Can I put all the configuration in one common config file and read from that instead of each of the 4 applicationname.exe.config file?

Upvotes: 0

Views: 561

Answers (2)

kay.one
kay.one

Reputation: 7692

You can use ConfigSource. Basically they allow you to reference different files within your app.config.

here is how it would work,

<configuration>
  <system.serviceModel>
    <services configSource="External.config" />
  </system.serviceModel>
</configuration>

External.config

<services>
   <!-- Put what you were going to put in the Service element-->
</services>

what you need to do is to 'refactor' the common parts from all the config files to external files and reference them from your main config files.

Upvotes: 1

DarthVader
DarthVader

Reputation: 55132

Yes you can do that. if you create a separate configuration project and refer to them from your different projects you can access the same key/value pairs. ie; configuration.

Look at my previous question.

Upvotes: 0

Related Questions