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

self starting windows service

Scheduled Pinned Locked Moved C#
data-structuresdebuggingquestion
3 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.
  • R Offline
    R Offline
    rakesh_nits
    wrote on last edited by
    #1

    hi all, i had created a windows service and added a projectinstaller .then in the afterinstall event i am trying to start it using serviceController it installs succesfully but it is not started and i get the following exception :System.InvalidOperationException: Cannot start service Service1 on computer '.'. ---> System.ComponentModel.Win32Exception: The service cannot be started, either because it is disabled or because it has no enabled devices associated with it --- End of inner exception stack trace --- at System.ServiceProcess.ServiceController.Start(String[] args) at System.ServiceProcess.ServiceController.Start() at TestWindowsService.ProjectInstaller.serviceInstaller1_AfterUninstall(Object sender, InstallEventArgs e) and now if unsinstall it starts it seems afterinstall event is called in both after install and after uninstall.how can i make this service self starting i hadn't added any extra code(except in the afterinstallevent) in the windows service. ServiceController sc = new ServiceController("Service1"); sc.Start(); sc.Close(); i am using the windows service template. thanks in advance. Rakesh

    R 1 Reply Last reply
    0
    • R rakesh_nits

      hi all, i had created a windows service and added a projectinstaller .then in the afterinstall event i am trying to start it using serviceController it installs succesfully but it is not started and i get the following exception :System.InvalidOperationException: Cannot start service Service1 on computer '.'. ---> System.ComponentModel.Win32Exception: The service cannot be started, either because it is disabled or because it has no enabled devices associated with it --- End of inner exception stack trace --- at System.ServiceProcess.ServiceController.Start(String[] args) at System.ServiceProcess.ServiceController.Start() at TestWindowsService.ProjectInstaller.serviceInstaller1_AfterUninstall(Object sender, InstallEventArgs e) and now if unsinstall it starts it seems afterinstall event is called in both after install and after uninstall.how can i make this service self starting i hadn't added any extra code(except in the afterinstallevent) in the windows service. ServiceController sc = new ServiceController("Service1"); sc.Start(); sc.Close(); i am using the windows service template. thanks in advance. Rakesh

      R Offline
      R Offline
      Robert Rohde
      wrote on last edited by
      #2

      Have you checked whether the service starts up correctly when doing it manually via control panel?

      R 1 Reply Last reply
      0
      • R Robert Rohde

        Have you checked whether the service starts up correctly when doing it manually via control panel?

        R Offline
        R Offline
        rakesh_nits
        wrote on last edited by
        #3

        Hi robert, yes, i checked and it was starting perfectly.after being installed with installutil.any idea what is causing the problem.thanks in Advance. Rakesh

        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