Solved

Use one app.config for multiple exe files

Posted on 2011-03-09
8
478 Views
Last Modified: 2012-08-13
I have created a solution in Visual Studio 2008 that has 5 console app projects. They call a common app.config. When I build them, each project creates it's own version of the app.config, called something like DataFTP.exe.config. If something changes I don't want to have to change all the config files. I don't see any settings in Visual Studio or by opening the .proj files in a text editor. Can anyone tell me how to do this?
Thanks,
0
Comment
Question by:asaworker
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 11

Expert Comment

by:jasonduan
ID: 35087854
One way to workaround this is to use "build events"

From Visual Studio, right click the project, then "Properties", then "Build Events" tab, you can put copy command there.
0
 

Author Comment

by:asaworker
ID: 35088204
What is the copy comand?
0
 

Author Comment

by:asaworker
ID: 35088221
I see Pre-buid event command line, and also Post-build command line.
 How will the exe file know to use the common app.config, instead of the exe-specific file?
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 5

Expert Comment

by:morgulo
ID: 35088396
You can use custom config file:

ExeConfigurationFileMap map = new ExeConfigurationFileMap();
map.ExeConfigFilename = "config.file";
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);

Open in new window

0
 

Author Comment

by:asaworker
ID: 35088446
Do you mean those lines would go in the Pre-build event command line or Post-build command line fields?
0
 

Author Comment

by:asaworker
ID: 35088519
I found http://msdn.microsoft.com/en-us/library/system.configuration.configurationmanager.openmappedexeconfiguration.aspx, but I'm not sure what it means. Is this a class file that I include in each project? Does program.cs have to call this file?
0
 

Author Comment

by:asaworker
ID: 35088764
I am using Framework 3.5
0
 
LVL 5

Accepted Solution

by:
Divinity earned 500 total points
ID: 35093628
If your problem is dat you want to use the same .config file for each console application once it has been compiled and is ready for use, then you should use morgulo's solution, which suggests a custom config file.

If however you don't care that each console application has it's own .config file, but you want to use the same file during development, you can do the following:
- Add the .config file to one of the console app projects.
- On the other four projects, right-click the project and choose "Add Existing Item".
- Browse to the .config file in the first project's folder and select it.
- Don't click "Add" but click the arrow next to it.
- Choose "Add as link" from the dropdown menu.
Now all projects use the same file when building the solution.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question