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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Configuring a windows service via GUI - C#

  • 05-07-2011 10:33am
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 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, Registered Users 2 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, Registered Users 2 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, Registered Users 2 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, Registered Users 2 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,611 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