Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / September 2005

Tip: Looking for answers? Try searching our database.

Error during start of Windows Service...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tom - 29 Sep 2005 18:23 GMT
Got another question on my Windows Service which I coded in
VB.NET. During the OnStart event (when the service is
started) I set up a database connection that my service
uses. Let's say something occurs during the middle of this
- or any other error - which would cause my service to NOT
start up. How should one handle that? Obviously, using a
Try...Catch - but my question deals with how to tell the
Windows Service Manager that the service didn't start? On
some events you have an e.Cancel or such to say that
validation didn't work - was wondering if there was
something like that for a service.

If, for instance, I catch an error in my OnStart method,
what do I do then to tell the Service Manager my service
didn't start up correctly? I wouldn't want the Service
Manager to say my service is running when in fact it got an
error and I caught it but couldn't continue.

Hope this makes sense. Thanks in advance.

Tom
Willy Denoyette [MVP] - 30 Sep 2005 15:26 GMT
> Got another question on my Windows Service which I coded in
> VB.NET. During the OnStart event (when the service is
[quoted text clipped - 17 lines]
>
> Tom

Just throw an exception, this will return to the SCM who will post a message
into the application eventlog and terminate your service.

Willy.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.