I'm building a set of Console applications which all need to reference a web service. I have a class library which contains much of the shared functionality of these applications, including the web service (which has been added as a service reference). I know that the "correct" way to handle this is to copy the block from the class library's app.config to each console app, but that causes maintenance headaches. I've also found the alternative of using a shared app.config file, with a reference to it from each app's config. That's better, but still not great - it still involves manually configuring each new app, and requires me to make sure the shared config file is in a place that all the apps can access.
What I'm looking for is one of three things (in declining order of satisfaction):
- A way to encapsulate the whole service, and everything necessary to access it, into the dll that's produced from the class library.
- A way to automatically copy the relevant config information into each console app's build directory (such as a post-build script).
- An explanation of why neither of the prior two is feasible. (In which case I'll go with the shared config)
Any advice?