views:

71

answers:

2

Hi everybody.

In my project I have a Windows Service and a WCF Service doing some actions on the same folder on a computer. The location of that folder will be given by the user within an app.config file that is included in the Windows Service project.

Now, I want the WCF Service to know the location of that folder (the folder given by the user), without the user having to type it into the WCF Service config file as well.

How would I go about doing that?

Thanks!

+1  A: 

You can place it in the Machine.config, and both the WCF application and the Windows service can access it.

http://msdn.microsoft.com/en-us/library/ms229697(VS.71).aspx

Kevin
While that will work, I would be careful about storing settings in Machine.config file. In general, it will pose a maintenance burden because it isn't a very common place to look for application specific configuration as opposed to the designated application configuration files. If you must however, then leave a clear reference as a remark in the application configuration files and/or in the source code.
Sandor Drieënhuizen
As a rule we keep all environment specific code in the machine.config. I wouldn't call it uncommon at all to place config values there.
Kevin
+1  A: 

There are lots of possibilities here:

  1. Add the path of the Windows Service's config file as a setting in the WCF service's config file, and use that path to read the file with an XML Reader.

  2. Store the folder path in some centralized system, like a database or the registry, and have both services obtain the setting from that centralized placed.

  3. Specify the path in each individual config file, but use a post build event to make sure they stay current. (For instance, maybe the post-build event retrieves the config setting from the DB and then writes it to the config file)

  4. Have one service expose the configuration setting as a public service call. For instance, the WCF service could invoke a method on the Windows service to determine which path to process.

Seth Petry-Johnson
Thanks! How does the public service call work?
Andrei