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. windows service

windows service

Scheduled Pinned Locked Moved C#
csharpquestion
26 Posts 5 Posters 2 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.
  • T tomorrow_ft

    no I didn't. also when restart comp. service's state is looking "beginning" and in event log says that "service start" but service's state is not to be "beginned"

    S Offline
    S Offline
    SeMartens
    wrote on last edited by
    #4

    Hmmm... maybe it hangs in the OnStart-event. Could you post the code of your OnStart()-method?

    It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

    T 2 Replies Last reply
    0
    • S SeMartens

      Hmmm... maybe it hangs in the OnStart-event. Could you post the code of your OnStart()-method?

      It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

      T Offline
      T Offline
      tomorrow_ft
      wrote on last edited by
      #5

      protected override void OnStart(string[] args) { inform("START");// for event log timer1.Start(); proccessorid();//I give all system info learnsystem(); Process.Start(string.Format("http://XXX.XXX.XX.X:4561/Default.aspx?proccessor\_Id={0}",proccessor.ToString()));//I send system info a web page }

      S P 2 Replies Last reply
      0
      • S SeMartens

        Hmmm... maybe it hangs in the OnStart-event. Could you post the code of your OnStart()-method?

        It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

        T Offline
        T Offline
        tomorrow_ft
        wrote on last edited by
        #6

        also it is rarely working on restart..

        1 Reply Last reply
        0
        • T tomorrow_ft

          protected override void OnStart(string[] args) { inform("START");// for event log timer1.Start(); proccessorid();//I give all system info learnsystem(); Process.Start(string.Format("http://XXX.XXX.XX.X:4561/Default.aspx?proccessor\_Id={0}",proccessor.ToString()));//I send system info a web page }

          S Offline
          S Offline
          SeMartens
          wrote on last edited by
          #7

          I would suggest that you write to the event log after each call (timer1start(), processorid()...) This will show you when your service hangs...

          It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

          T 1 Reply Last reply
          0
          • T tomorrow_ft

            hi I wrote a windows service in c# that its starttype is aoutomatic but when I restart or start the computer it's not working. it is only working manual why its happen?? thanks

            B Offline
            B Offline
            Bernhard Hiller
            wrote on last edited by
            #8

            Is your service dependent on another service? Then make sure that the other service is started before.

            T 1 Reply Last reply
            0
            • S SeMartens

              I would suggest that you write to the event log after each call (timer1start(), processorid()...) This will show you when your service hangs...

              It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

              T Offline
              T Offline
              tomorrow_ft
              wrote on last edited by
              #9

              no event log doesn't work after functions. but it is working manual succesfully

              S 1 Reply Last reply
              0
              • B Bernhard Hiller

                Is your service dependent on another service? Then make sure that the other service is started before.

                T Offline
                T Offline
                tomorrow_ft
                wrote on last edited by
                #10

                a lot of services start before which is depend on how am I understand?

                L 1 Reply Last reply
                0
                • T tomorrow_ft

                  no event log doesn't work after functions. but it is working manual succesfully

                  S Offline
                  S Offline
                  SeMartens
                  wrote on last edited by
                  #11

                  Ok, and after which function? You should try to log to the disk (fixed file would be sufficient first) so that you can reconstruct the point of failure...

                  It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

                  T 1 Reply Last reply
                  0
                  • S SeMartens

                    Ok, and after which function? You should try to log to the disk (fixed file would be sufficient first) so that you can reconstruct the point of failure...

                    It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

                    T Offline
                    T Offline
                    tomorrow_ft
                    wrote on last edited by
                    #12

                    "You should try to log to the disk" How am I doing it??

                    S 1 Reply Last reply
                    0
                    • T tomorrow_ft

                      "You should try to log to the disk" How am I doing it??

                      S Offline
                      S Offline
                      SeMartens
                      wrote on last edited by
                      #13

                      You have several possibilities: 1. Use log4net: http://logging.apache.org/log4net/index.html[^] 2. Directly writing to a file: http://msdn.microsoft.com/en-us/library/aa287548%28VS.71%29.aspx[^]

                      It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

                      T 1 Reply Last reply
                      0
                      • S SeMartens

                        You have several possibilities: 1. Use log4net: http://logging.apache.org/log4net/index.html[^] 2. Directly writing to a file: http://msdn.microsoft.com/en-us/library/aa287548%28VS.71%29.aspx[^]

                        It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

                        T Offline
                        T Offline
                        tomorrow_ft
                        wrote on last edited by
                        #14

                        sorry I didn't understand like this.I can it. I will test it too, thanks..

                        1 Reply Last reply
                        0
                        • T tomorrow_ft

                          protected override void OnStart(string[] args) { inform("START");// for event log timer1.Start(); proccessorid();//I give all system info learnsystem(); Process.Start(string.Format("http://XXX.XXX.XX.X:4561/Default.aspx?proccessor\_Id={0}",proccessor.ToString()));//I send system info a web page }

                          P Offline
                          P Offline
                          PIEBALDconsult
                          wrote on last edited by
                          #15

                          A wild guess is that the Process.Start can't run at that time (for whatever reason). Maybe put it in a try, wait and loop a few times if it fails.

                          for maybe three times
                          try
                          Process.Start
                          break
                          catch
                          wait a minute or so

                          Better yet, run that on a separate thread so the OnStart completes in a timely manner.

                          T 1 Reply Last reply
                          0
                          • P PIEBALDconsult

                            A wild guess is that the Process.Start can't run at that time (for whatever reason). Maybe put it in a try, wait and loop a few times if it fails.

                            for maybe three times
                            try
                            Process.Start
                            break
                            catch
                            wait a minute or so

                            Better yet, run that on a separate thread so the OnStart completes in a timely manner.

                            T Offline
                            T Offline
                            tomorrow_ft
                            wrote on last edited by
                            #16

                            hi all I put out the "Process.start" code, but it is not working. Only first inform("start") works, anothers not work Thats no problem on manual..

                            P 1 Reply Last reply
                            0
                            • T tomorrow_ft

                              hi all I put out the "Process.start" code, but it is not working. Only first inform("start") works, anothers not work Thats no problem on manual..

                              P Offline
                              P Offline
                              PIEBALDconsult
                              wrote on last edited by
                              #17

                              What does the code look like now?

                              T 1 Reply Last reply
                              0
                              • P PIEBALDconsult

                                What does the code look like now?

                                T Offline
                                T Offline
                                tomorrow_ft
                                wrote on last edited by
                                #18

                                protected override void OnStart(string[] args) { inform("START");// for event log timer1.Start(); proccessorid();//I give all system info learnsystem(); }

                                T P 2 Replies Last reply
                                0
                                • T tomorrow_ft

                                  protected override void OnStart(string[] args) { inform("START");// for event log timer1.Start(); proccessorid();//I give all system info learnsystem(); }

                                  T Offline
                                  T Offline
                                  tomorrow_ft
                                  wrote on last edited by
                                  #19

                                  I think when I try learning proccesorid and all system info , the code is failed. I put out them and service started normally in boot.. But I have to take those informations.

                                  1 Reply Last reply
                                  0
                                  • T tomorrow_ft

                                    a lot of services start before which is depend on how am I understand?

                                    L Offline
                                    L Offline
                                    Lost User
                                    wrote on last edited by
                                    #20

                                    Open services.msc. Right click on any service. You can see properties menu in pop menu. When you open properties of the service. you will see dependencies tab. Regards, Sunil G.

                                    T 1 Reply Last reply
                                    0
                                    • L Lost User

                                      Open services.msc. Right click on any service. You can see properties menu in pop menu. When you open properties of the service. you will see dependencies tab. Regards, Sunil G.

                                      T Offline
                                      T Offline
                                      tomorrow_ft
                                      wrote on last edited by
                                      #21

                                      no dependencies

                                      L 1 Reply Last reply
                                      0
                                      • T tomorrow_ft

                                        no dependencies

                                        L Offline
                                        L Offline
                                        Lost User
                                        wrote on last edited by
                                        #22

                                        Have you tried to change the start type of your to automatic.

                                        T 1 Reply Last reply
                                        0
                                        • L Lost User

                                          Have you tried to change the start type of your to automatic.

                                          T Offline
                                          T Offline
                                          tomorrow_ft
                                          wrote on last edited by
                                          #23

                                          anyway start type is automatic

                                          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