Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. how to monitor the Status of the windows service ?

how to monitor the Status of the windows service ?

Scheduled Pinned Locked Moved C#
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sundar156
    wrote on last edited by
    #1

    Hi, how to monitor the status of the service from a utility developed in c#,I came to know that we can use either System.ServiceProcess.ServiceController class or WMI.Which is more robust,and feasible way.....I have to start,Stop and pause a service ,the App.config file has settings like polling time...I am not able to modify the service during runtime if i make change to the App.config after installing the service.So is it Feasible to modify the Application.exe.config file during runtime to make the changes take effect during runtime...

    K 1 Reply Last reply
    0
    • S sundar156

      Hi, how to monitor the status of the service from a utility developed in c#,I came to know that we can use either System.ServiceProcess.ServiceController class or WMI.Which is more robust,and feasible way.....I have to start,Stop and pause a service ,the App.config file has settings like polling time...I am not able to modify the service during runtime if i make change to the App.config after installing the service.So is it Feasible to modify the Application.exe.config file during runtime to make the changes take effect during runtime...

      K Offline
      K Offline
      kubben
      wrote on last edited by
      #2

      Unless you are doing something custom your windows service will load the app.config on start. You can make changes to the app.config while the window service is running, but they will not take affect until the service is stopped and re-started. If you have some custom code that re-reads the app.config file every time, then you might be able to get that to work. Otherwise you will need to stop and restart the service. Ben

      S 1 Reply Last reply
      0
      • K kubben

        Unless you are doing something custom your windows service will load the app.config on start. You can make changes to the app.config while the window service is running, but they will not take affect until the service is stopped and re-started. If you have some custom code that re-reads the app.config file every time, then you might be able to get that to work. Otherwise you will need to stop and restart the service. Ben

        S Offline
        S Offline
        sundar156
        wrote on last edited by
        #3

        hi, The changes made in the App.config will not take effect even ater stopping and starting the service , not untill you recompile the solution....

        people laugh at me because they say im different and I laugh at them because they are all the same.

        K 1 Reply Last reply
        0
        • S sundar156

          hi, The changes made in the App.config will not take effect even ater stopping and starting the service , not untill you recompile the solution....

          people laugh at me because they say im different and I laugh at them because they are all the same.

          K Offline
          K Offline
          kubben
          wrote on last edited by
          #4

          No that is not true. When you stop the service and start it again the app.config is read again. Now if you mean literally that if you make changes to the app.config file, then yes you need to recompile. But you should be changing the programname.exe.config file. where programname is replaced with what ever you call your service. When you change that file and stop and start the service it will pick up the change. Just make sure you update the app.config in your project as well. Ben

          S 1 Reply Last reply
          0
          • K kubben

            No that is not true. When you stop the service and start it again the app.config is read again. Now if you mean literally that if you make changes to the app.config file, then yes you need to recompile. But you should be changing the programname.exe.config file. where programname is replaced with what ever you call your service. When you change that file and stop and start the service it will pick up the change. Just make sure you update the app.config in your project as well. Ben

            S Offline
            S Offline
            sundar156
            wrote on last edited by
            #5

            Thanks, After the service is installed it is not going to be recompiled in any way..So why do i at all make changes to the App.config file...Please clarify..

            people laugh at me because they say im different and I laugh at them because they are all the same.

            K 1 Reply Last reply
            0
            • S sundar156

              Thanks, After the service is installed it is not going to be recompiled in any way..So why do i at all make changes to the App.config file...Please clarify..

              people laugh at me because they say im different and I laugh at them because they are all the same.

              K Offline
              K Offline
              kubben
              wrote on last edited by
              #6

              When you install your service, you need to have at least two files. One is the exe file. The other is the exe.config file. The exe.config file is created when you compile your project from the app.config. You can update the exe.config file directly and stop and start the service and it will use the new config settings. So if you service is called MyService the exe would be MyService.exe and the config file would be MyService.exe.config. Hope that helps. Ben

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups