1

I use My.Settings object in VB.NET, which automatically gets application setting from AppName.exe.config file. How can I store config in file with other name, not AppName.exe.config? I have several programs, all of them now uses their own .config file, but in fact they all are clones, and if I change some setting I need to edit several configs.

J. Steen
  • 15,470
  • 15
  • 56
  • 63
dmitry
  • 468
  • 1
  • 4
  • 18
  • 1
    I looked for this one time when I was trying to figure out how to read some settings from two different applications, each using a single WCF client .dll and as I recall the answer is (at least at that time, about a year ago) was that it can't be done. If you need to keep a common settings file you could perhaps use post-build commands to copy it to different names. If you are just reading in settings that don't need to necessarily be in the app.config/web.config file, then you can always just put them in a common file other than the app config, and then load the settings manually. – shelleybutterfly Aug 27 '11 at 19:35

1 Answers1

0

This will work with <appSettings>, not sure if it works with the Settings
Design time
Put the app.config file in the solution folder so one level up from a project. For each of your projects in the solution explorer do the following
- Add > Existing Item
- Browse to app.config in solution root > Add As Link (small arrow near to the Add button)

Run time
You can use this code to load config (C#)

var fileMap = new ConfigurationFileMap(pathToConfig);  
var configuration = ConfigurationManager.OpenMappedMachineConfiguration(fileMap);
oleksii
  • 35,458
  • 16
  • 93
  • 163