Problem with windows service OnStop event

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • karthi84
    Contributor
    • Dec 2006
    • 270

    #1

    Problem with windows service OnStop event

    Hi,
    I have created a windows service and i have written code in OnStart and OnStop event. when i manually start and stop the service it works fine. But when i restart the machine the OnStop event is not working but the OnStart event is working fine. This service depends on network connection for storing data to a remote DB. I have attached the 'netman(network connection)' in the service dependency. There is no error message in the event viewer also.
    If this is not the correct location to post this question please re-direct this question to the corresponding section.

    Thanks & Regards
    karthi
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    You put code in the OnShutDown method of you want it to be executed when the computer is shut down while the service is running.

    Comment

    • karthi84
      Contributor
      • Dec 2006
      • 270

      #3
      Originally posted by r035198x
      You put code in the OnShutDown method of you want it to be executed when the computer is shut down while the service is running.
      when i tried with OnShutDown i get the following error

      Error 1 'Test.OnShutDow n()': no suitable method found to override F:\Dot Net Works\Projects\ Test\Service1.c s 72 33 Test



      I am new to services. Please explain me in solving this problem

      Comment

      • karthi84
        Contributor
        • Dec 2006
        • 270

        #4
        Originally posted by r035198x
        You put code in the OnShutDown method of you want it to be executed when the computer is shut down while the service is running.
        thanks r035198x ,
        I have got this issue fixed.

        Comment

        Working...