¿Cómo cambiar el nombre del archivo de configuración de la aplicación (AppName.exe.config)?

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.

preguntado el 27 de agosto de 11 a las 18:08

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. -

1 Respuestas

Esto funcionará con <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)

Tiempo de ejecución
You can use this code to load config (C#)

var fileMap = new ConfigurationFileMap(pathToConfig);  
var configuration = ConfigurationManager.OpenMappedMachineConfiguration(fileMap);

Respondido 28 ago 11, 01:08

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.