Creating a service

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • K Viltersten

    Creating a service

    I see in the examples at MSDN that when a
    service is created, Main method is still
    there, as the code below shows. Why is it
    there?! I'd expect OnStart to be the only
    required entry point for a service.

    public static void Main() {
    System.ServiceP rocess.
    ServiceBase.Run (new UserService1()) ;}


    --
    Regards
    Konrad Viltersten
    ----------------------------------------
    May all spammers die an agonizing death;
    have no burial places; their souls be
    chased by demons in Gehenna from one room
    to another for all eternity and beyond.


  • Pavel Minaev

    #2
    Re: Creating a service

    "K Viltersten" <tmp1@vilterste n.comwrote in message
    news:6i6uf4Fpbd e3U1@mid.indivi dual.net...
    >I see in the examples at MSDN that when a
    service is created, Main method is still
    there, as the code below shows. Why is it
    there?! I'd expect OnStart to be the only
    required entry point for a service.
    A service application is still a Windows .exe, and as such its entry point
    is Main. It actually becomes a service process only after it registers
    itself with the Service Control Manager, which is what ServiceBase.Run does.


    Comment

    • K Viltersten

      #3
      Re: Creating a service

      Got it, thanks.

      In that case, i wonder why i need to
      install the service. If the registration
      is done in Main, it seems superfluous to
      to that using installutil.exe as well.

      What do i miss?

      --
      Regards
      Konrad Viltersten
      ----------------------------------------
      May all spammers die an agonizing death;
      have no burial places; their souls be
      chased by demons in Gehenna from one room
      to another for all eternity and beyond.
      "Pavel Minaev" <int19h@gmail.c omskrev i meddelandet
      news:O0Tc20ZDJH A.5196@TK2MSFTN GP04.phx.gbl...
      "K Viltersten" <tmp1@vilterste n.comwrote in message
      news:6i6uf4Fpbd e3U1@mid.indivi dual.net...
      >>I see in the examples at MSDN that when a
      >service is created, Main method is still
      >there, as the code below shows. Why is it
      >there?! I'd expect OnStart to be the only
      >required entry point for a service.
      >
      A service application is still a Windows .exe, and as such its entry point
      is Main. It actually becomes a service process only after it registers
      itself with the Service Control Manager, which is what ServiceBase.Run
      does.
      >

      Comment

      • Pavel Minaev

        #4
        Re: Creating a service

        "K Viltersten" <tmp1@vilterste n.comwrote in message
        news:6i73k1Fp29 qlU1@mid.indivi dual.net...
        Got it, thanks.
        >
        In that case, i wonder why i need to
        install the service. If the registration
        is done in Main, it seems superfluous to
        to that using installutil.exe as well.
        >
        What do i miss?
        Registration of the specific running _process_ as a service is done in Main,
        not of the executable. You still need to register the executable for it to
        appear in the list of services.


        Comment

        • K Viltersten

          #5
          Re: Creating a service

          >Got it, thanks.
          >>
          >In that case, i wonder why i need to
          >install the service. If the registration
          >is done in Main, it seems superfluous to
          >to that using installutil.exe as well.
          >>
          >What do i miss?
          >
          Registration of the specific running _process_ as a service is done in
          Main, not of the executable. You still need to register the executable for
          it to appear in the list of services.
          Got it, thanks!

          Hey, how come my post went top-posted?!
          It was unintentional, sorry...

          --
          Regards
          Konrad Viltersten
          ----------------------------------------
          May all spammers die an agonizing death;
          have no burial places; their souls be
          chased by demons in Gehenna from one room
          to another for all eternity and beyond.


          Comment

          Working...