Returning error during service startup

  • Thread starter Thread starter matt breedlove
  • Start date Start date
M

matt breedlove

(x-posted to microsoft.public.dotnet.general and
microsoft.public.dotnet.languages.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
 
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.Diagnostic EventLog class. You can then use a Service
Controller to gracefully pause or stop your service.

-Rob Teixeira [MVP]
 
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
 
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
 
Back
Top