Deployment of Windows Service and Web App - share common config file RRS feed

  • Question

  • We are developing a Windows Sevice and Web App that will run on the same server.  These are setup as two seperate projects under one solution within Visual Studio.  Our goal is to share config files (properties) between the two projects.  We don't want to maintain two configuration files.  We would also like to have these config files to be dynamically reloaded if they are changed during runtime.

    The three solutions that I can find are:
    (1) Duplicate all of the properties in the config files under both projects.  We would like to avoid this.
    (2) Reference an external file in the config files.  This is good but from what I read it doesn't automatically reload the file if it is changed during runtime.
    (3) Provide a Class in one of the projects that will read the properties from its config file.  For example, in Project A we will have a class that reads properties from its config file.  If Project B needs to access properties it will call the class in Project A which will access the config fiel for project A.  The only issue I see with this is that I would have to have a common deployment directory where I store both the web app and windows service so I can share the same config file.

    Is it a bad practice to deploy both the web app and windows service to the same directory?

    Does anyone have any suggestions?  Or have any experience on what I am trying to do?

    Thanks for the help.

    Wednesday, February 13, 2008 3:26 PM


All replies

  • Hi Mark,


    It's hard to say that it is a "bad practice". Rather unusual...

    As I understand here you need to configure your Windows Service from Web Application, right?

    We had similar situation: we needed to configure (and read settings of) Windows Service from Web application.

    We used .NET Remoting to achieve this goal. We didn't used shared config file neither duplicated config files.



    Wednesday, February 13, 2008 4:36 PM
  • My goal is to share a configuration file between a Web App and Windows Service.  With the ability for the file to be reloaded if something was changed.
    Wednesday, February 13, 2008 4:54 PM
  • You can use shared config file and poll the configuration file using a timer to monitor its change.
    Thursday, February 14, 2008 12:29 AM

  • I am newer to .Net came from Java.  Can you expand on your answer a little?  You mention to use a shared config file... Is there such a thing as a shared config file in .Net?  Or are you talking about writing my own class that will manage a "shared" (common) config file.  For example, create a class named "ConfigFileManager" which will load the file and all clients will have to ask this class for the properties.  I was thinking about using the FileSystemMonitor to detect changes to the property file so my class will just reload the properties when it detects that the file has been changed.

    Are there some .Net classes that I should be inheriting from??

    Thanks for the help.


    Thursday, February 14, 2008 1:00 AM
  • You can use a XML file as the shared configuration file. And use XML access classes to read and write it. For more details, please visit the following references:
    Configuration File Reader
    Read/Write XML files, Config files, INI files, or the Registry
    Thursday, February 14, 2008 6:19 AM