Click here to Skip to main content
15,921,531 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I have a solution include:
+ Project 1 (P1): 1 Windows Form Control Library (WFCL), 1 dataset and 1 app.config
+ P2: similar P1
+ P3: is windows form, i use P1 and P2 in P3
When i debug P3, all thing is ok although in P3 still have not app.config.
Pls everyone help me to solve 2 situation when i creat set up file for P3 and may be install in any system when i want to change connect string:
+ S1: both P1 and P2 using common database (only database)
+ S2: P1 use database of P1, P2 use database of P2

Pls help me,
Thanks!
Posted

1 solution

I an app won't refer to multiple config files. But it can have multiple settings file or may have multiple sections in the config file.

Have a app config in the P3.

Use a settings file (may be p1Settings.settings). Enter your connection strings and other settings here. Once you saved this your app config will have the connection strings.

When you reference then dll from other Form projects (p3). Right click ->Add Existing item, select the p1Settings.setting file from the library project path. This will add the settings file to the current project. Move this file under the properties section in the solution explorer. Open this settings file and enter a dummy value in the designer and save. Now these entries will be append to the Form project's (p3) config file.

Open the app config file now, you can see all the settings from the settings file append here. But one thing this p3 projects name is append in all the setting's name. Replace that with your library project name.

Now your library read the app config of p3 which provide the same settings as in the library. You can edit any settings in the config file.

I think that's what you can do. If the settings in the library project are few then copy and paste those to the p3's app config to the appropriate sections.

Search net if there is better solution available.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900