Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Configuring a windows service via GUI - C#

Options
  • 05-07-2011 11:33am
    #1
    Registered Users Posts: 324 ✭✭


    Hi there,

    I have a windows service running which writes to an online or local DB depending on connection status. There are a number of settings it depends on, currently stored in a database. I would like to be able to alter these as these service runs (possible?) using a GUI. The settings will soon be stored locally.

    Is it correct to say I should have a seperate winforms application that will configure a settings file read by the service? I was considering using the service's app.config file with custom sections, but can I access this file externally? Would it be better to store the setting in the local database (SQLite) since it is already implemented?

    Any help/advice would great! Much appreciated


Comments

  • Registered Users Posts: 981 ✭✭✭fasty


    I handled this by hosting a WCF service in the Windows service and having the GUI connect to the service. This works both locally and if you like, remotely because you can run the service over http.


  • Registered Users Posts: 324 ✭✭greyed


    Cheeris fasty, could you tell me if WCF is supported by Mono? as this service will need to be portable.


  • Registered Users Posts: 9,579 ✭✭✭Webmonkey


    greyed wrote: »
    Cheeris fasty, could you tell me if WCF is supported by Mono? as this service will need to be portable.
    http://www.mono-project.com/WCF


  • Registered Users Posts: 324 ✭✭greyed


    Thanks webmonkey, I was aware of that particular page alright, unfortunately I am a little overwhelmed by all the considerations for cross-platform development, so I am not sure which classes of WCF I would need. Could you explain a little more about WCF service hosting or do you know of any good tutorials/resources?

    As an alternative, I am considering altering the app.config file from a seperate GUI as discussed here.


  • Registered Users Posts: 324 ✭✭greyed


    Unfortunately, the component I need from WCF is not currently implemented in mono, and so is not a portable solution :/

    If I was to edit a DB of settings, where could I store a single integer (along with other associated lists)? Or is such a configuration structure reason enough not to use one?


  • Advertisement
  • Closed Accounts Posts: 25 iDigian


    greyed wrote: »
    Unfortunately, the component I need from WCF is not currently implemented in mono, and so is not a portable solution :/

    If I was to edit a DB of settings, where could I store a single integer (along with other associated lists)? Or is such a configuration structure reason enough not to use one?

    If memory serves me correct you can do the following,
    1) Create a class library called "CstmConfig.dl" which contains the classes behind your custom config section.

    2) Compile this into the service and add custom sections to the app.config.

    3) Create a separate app which is to be used for config and add the CstmConfig.dll to it and then do whatever config you need to and then write config file. Changes will only take affect if either you reload config from within service or restart service. You can trigger reload config with a filewatcher.

    It should work in theory.


  • Moderators, Business & Finance Moderators Posts: 10,286 Mod ✭✭✭✭Jim2007


    iDigian wrote: »
    If memory serves me correct you can do the following,
    1) Create a class library called "CstmConfig.dl" which contains the classes behind your custom config section.

    2) Compile this into the service and add custom sections to the app.config.

    3) Create a separate app which is to be used for config and add the CstmConfig.dll to it and then do whatever config you need to and then write config file. Changes will only take affect if either you reload config from within service or restart service. You can trigger reload config with a filewatcher.

    It should work in theory.

    Good answer, it is always a good idea to keep things simple...

    Jim.


Advertisement