Click here to Skip to main content
15,891,375 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have 4 projects

Project1(window project)

Project2(wpf project)

Project3(wpf project)

Project4(library Project)

all have own app config file,

i want to use single app config along multiple projects

how can i do thatt

i have tried to add app config file into solutions but there is no option to add application configuration file

or minimum have a single location for the connection string.
Posted

It looks to me that projects 2,3 & 4 are not standalone apps. I would not assign an app config file to a library project like that. I would write those apps such that they have constructors with everything they would need from the app config files. Then the calling project (Project1) would create the objects with those constructors. Thus, Project1 is the only project that needs an app config file.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 5-Oct-11 14:14pm    
Good point, my 5.
However, if OP really needs it by some reason (I doubt it as you are right), there is a way, please see my solution.
--SA
Simon Bang Terkildsen 6-Oct-11 8:17am    
+5
If you really want to do that, take a look at:
MSBuild Copy Task[^]

Best regards
Espen Harlinn
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 5-Oct-11 14:13pm    
Yes, my 5 (just for knowing it :-), but this is for custom build with custom tasks. There is a much simpler way; please see my solution.
--SA
Espen Harlinn 6-Oct-11 10:26am    
Thank you, Sergey!
Simon Bang Terkildsen 6-Oct-11 8:18am    
got my 5
Espen Harlinn 6-Oct-11 10:26am    
Thank you, Simon!
If you really want to do this (which I'm not sure, see the answer by Roy), there is a way, in principle.

For one project, do: [Solution Explorer]: "Add" => "Add New Item" => "General" => "Application Configuration file".

For other projects, use the same file in the following way:
[Solution Explorer]: "Add" => "Add Existing Item" =>
[In file dialog box: select the same file => "Add" (small right down arrow) => "Add As Link" ]

The key here is "Add As Link". You will have only one physical file, linked to more than one project of the same solution.

—SA
 
Share this answer
 
v4
Comments
Espen Harlinn 5-Oct-11 14:57pm    
5'ed - as usual :)
Sergey Alexandrovich Kryukov 5-Oct-11 15:01pm    
Thank you, Espen.
--SA
Simon Bang Terkildsen 6-Oct-11 8:19am    
Absolutely the best way to do it, my 5.
Sergey Alexandrovich Kryukov 6-Oct-11 11:49am    
Thank you, Simon, but there is much better way: to avoid overly strong coupling between projects.

In a good code design, just referencing is usually quite enough; in other cases (plug-ins) dynamic loading of assembly and invocation of implementation of an interface via Reflection works well. Anything beyond that is from devil -- usually.
--SA
Thanks. but solution is not corrected
 
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