Returning error during service startup

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • matt breedlove

    Returning error during service startup

    (x-posted to microsoft.publi c.dotnet.genera l and
    microsoft.publi c.dotnet.langua ges.vb)

    Hello all.

    I am currently creating a Windows Service using VB.NET and would like to
    return an error if something goes wrong during startup, IE: parsing a
    configuration file.

    The only way I know of is to throw an exception, and this will prevent the
    service from starting. However it will not display an error message. Using
    this method, I get the following:

    Could not start the <service name> on Local Computer.
    The service did not return an error. This could be an internal
    Windows error or an internal service error.
    If the problem persists, contact your system administrator.

    The error message leads me to believe it is possible to return an error, but
    I have not been able to find any documentation as to how to do this.

    Any help would be greatly appreciated,

    Thanks,
    -matt


  • Rob Teixeira [MVP]

    #2
    Re: Returning error during service startup

    Instead of raising the error, write a detailed event log entry (which can
    include a complete exception and its stack trace for debugging purposes)
    using the System.Diagnost ic EventLog class. You can then use a Service
    Controller to gracefully pause or stop your service.

    -Rob Teixeira [MVP]

    "matt breedlove" <sirmalloc@gmx. net> wrote in message
    news:6noec.1081 9$I83.280959@tw ister.tampabay. rr.com...[color=blue]
    > (x-posted to microsoft.publi c.dotnet.genera l and
    > microsoft.publi c.dotnet.langua ges.vb)
    >
    > Hello all.
    >
    > I am currently creating a Windows Service using VB.NET and would like to
    > return an error if something goes wrong during startup, IE: parsing a
    > configuration file.
    >
    > The only way I know of is to throw an exception, and this will prevent the
    > service from starting. However it will not display an error message.[/color]
    Using[color=blue]
    > this method, I get the following:
    >
    > Could not start the <service name> on Local Computer.
    > The service did not return an error. This could be an internal
    > Windows error or an internal service error.
    > If the problem persists, contact your system administrator.
    >
    > The error message leads me to believe it is possible to return an error,[/color]
    but[color=blue]
    > I have not been able to find any documentation as to how to do this.
    >
    > Any help would be greatly appreciated,
    >
    > Thanks,
    > -matt
    >
    >[/color]


    Comment

    • Rob Teixeira [MVP]

      #3
      Re: Returning error during service startup

      Instead of raising the error, write a detailed event log entry (which can
      include a complete exception and its stack trace for debugging purposes)
      using the System.Diagnost ic EventLog class. You can then use a Service
      Controller to gracefully pause or stop your service.

      -Rob Teixeira [MVP]

      "matt breedlove" <sirmalloc@gmx. net> wrote in message
      news:6noec.1081 9$I83.280959@tw ister.tampabay. rr.com...[color=blue]
      > (x-posted to microsoft.publi c.dotnet.genera l and
      > microsoft.publi c.dotnet.langua ges.vb)
      >
      > Hello all.
      >
      > I am currently creating a Windows Service using VB.NET and would like to
      > return an error if something goes wrong during startup, IE: parsing a
      > configuration file.
      >
      > The only way I know of is to throw an exception, and this will prevent the
      > service from starting. However it will not display an error message.[/color]
      Using[color=blue]
      > this method, I get the following:
      >
      > Could not start the <service name> on Local Computer.
      > The service did not return an error. This could be an internal
      > Windows error or an internal service error.
      > If the problem persists, contact your system administrator.
      >
      > The error message leads me to believe it is possible to return an error,[/color]
      but[color=blue]
      > I have not been able to find any documentation as to how to do this.
      >
      > Any help would be greatly appreciated,
      >
      > Thanks,
      > -matt
      >
      >[/color]


      Comment

      • matt breedlove

        #4
        Re: Returning error during service startup

        I'm currently writing the detailed exception to the event log, I was just
        wondering if there was a more appropriate way to stop the service and return
        an informational message at that point, rather than no message at all and
        require the user to check the event log.

        Thanks for the input,
        -matt


        "Rob Teixeira [MVP]" <RobTeixeira@@m sn.com> wrote in message
        news:ORdK4HFIEH A.2128@TK2MSFTN GP11.phx.gbl...[color=blue]
        > Instead of raising the error, write a detailed event log entry (which can
        > include a complete exception and its stack trace for debugging purposes)
        > using the System.Diagnost ic EventLog class. You can then use a Service
        > Controller to gracefully pause or stop your service.
        >
        > -Rob Teixeira [MVP]
        >
        > "matt breedlove" <sirmalloc@gmx. net> wrote in message
        > news:6noec.1081 9$I83.280959@tw ister.tampabay. rr.com...[color=green]
        > > (x-posted to microsoft.publi c.dotnet.genera l and
        > > microsoft.publi c.dotnet.langua ges.vb)
        > >
        > > Hello all.
        > >
        > > I am currently creating a Windows Service using VB.NET and would like to
        > > return an error if something goes wrong during startup, IE: parsing a
        > > configuration file.
        > >
        > > The only way I know of is to throw an exception, and this will prevent[/color][/color]
        the[color=blue][color=green]
        > > service from starting. However it will not display an error message.[/color]
        > Using[color=green]
        > > this method, I get the following:
        > >
        > > Could not start the <service name> on Local Computer.
        > > The service did not return an error. This could be an internal
        > > Windows error or an internal service error.
        > > If the problem persists, contact your system administrator.
        > >
        > > The error message leads me to believe it is possible to return an error,[/color]
        > but[color=green]
        > > I have not been able to find any documentation as to how to do this.
        > >
        > > Any help would be greatly appreciated,
        > >
        > > Thanks,
        > > -matt
        > >
        > >[/color]
        >
        >
        >[/color]


        Comment

        • matt breedlove

          #5
          Re: Returning error during service startup

          I'm currently writing the detailed exception to the event log, I was just
          wondering if there was a more appropriate way to stop the service and return
          an informational message at that point, rather than no message at all and
          require the user to check the event log.

          Thanks for the input,
          -matt


          "Rob Teixeira [MVP]" <RobTeixeira@@m sn.com> wrote in message
          news:ORdK4HFIEH A.2128@TK2MSFTN GP11.phx.gbl...[color=blue]
          > Instead of raising the error, write a detailed event log entry (which can
          > include a complete exception and its stack trace for debugging purposes)
          > using the System.Diagnost ic EventLog class. You can then use a Service
          > Controller to gracefully pause or stop your service.
          >
          > -Rob Teixeira [MVP]
          >
          > "matt breedlove" <sirmalloc@gmx. net> wrote in message
          > news:6noec.1081 9$I83.280959@tw ister.tampabay. rr.com...[color=green]
          > > (x-posted to microsoft.publi c.dotnet.genera l and
          > > microsoft.publi c.dotnet.langua ges.vb)
          > >
          > > Hello all.
          > >
          > > I am currently creating a Windows Service using VB.NET and would like to
          > > return an error if something goes wrong during startup, IE: parsing a
          > > configuration file.
          > >
          > > The only way I know of is to throw an exception, and this will prevent[/color][/color]
          the[color=blue][color=green]
          > > service from starting. However it will not display an error message.[/color]
          > Using[color=green]
          > > this method, I get the following:
          > >
          > > Could not start the <service name> on Local Computer.
          > > The service did not return an error. This could be an internal
          > > Windows error or an internal service error.
          > > If the problem persists, contact your system administrator.
          > >
          > > The error message leads me to believe it is possible to return an error,[/color]
          > but[color=green]
          > > I have not been able to find any documentation as to how to do this.
          > >
          > > Any help would be greatly appreciated,
          > >
          > > Thanks,
          > > -matt
          > >
          > >[/color]
          >
          >
          >[/color]


          Comment

          • Cor Ligthert

            #6
            Re: Returning error during service startup

            Hi Matt,

            How did you set up the function call to the webservice and how do you return
            the error in that?

            (Show us some code maybe we can help you than)

            Cor


            Comment

            • Cor Ligthert

              #7
              Re: Returning error during service startup

              Hi Matt,

              How did you set up the function call to the webservice and how do you return
              the error in that?

              (Show us some code maybe we can help you than)

              Cor


              Comment

              • Cor Ligthert

                #8
                Re: read error from me

                I saw my own read error.

                Cor


                Comment

                • Cor Ligthert

                  #9
                  Re: read error from me

                  I saw my own read error.

                  Cor


                  Comment

                  Working...