The title doesn't entirely describe the actual question, since I was trying to fit a succinct enough description into a one-liner.
I have a C# project I want to share between two different solutions (.sln). The project is an application with a Main method. It requires use of settings.settings and app.config. Each of the two solutions requires a reference to the same C# project, but for each solution, the app.config and settings.settings need to be specific to their solutions. So if project C is shared between solutions A and B, A includes C where C has an app.config specific to A, and B includes the same exact C project, but C has app.config specific to C. Is there a way to do this? I'm trying to avoid having to copy the same project (i.e. C) to two different locations, because if I update that project in one solution, then I have to make the same changes in another solution.
Thanks
Maybe you can use one of the Open...()
methods in ConfigurationManager
to achieve this. Otherwise, the following hack could work (except that you need to duplicate the entire App.config file): Create a minimal console app D1 in A and D2 in B, and call C's main()
method from here, and use D1 and D2 as the startup projects. Now, the App.config of D1 and D2 will be used in stead of C's App.config.
The project I want to share is actually shared between two different source control locations. I want to share the same project (i.e. C) between a SVN server solution and a TFS server solution. One solution I came up with which works (for more than one shared project, too) is to link the app.config in from a directory/branch located above the share project's directory. So instead of using the app.config located within project C's directory, you can have 2 different workspaces, and above project C's directory there is a folder called ApplicationSettings which has the app.config file. Each workspace, for each different solution, can maintain its own ApplicatonSettings folder, but can maintain the exact same copy of the shared project from source control.
I have a project at codeplex: http://wcfsilverlighthelper.codeplex.com/
That is a working example of what I mean. Look at the ApplicationSettings folder, and notice how the app.config files are used in the solution's T4 projects.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With