Groups | Blog | Home
all groups > dotnet myservices > december 2005 >

dotnet myservices : Conditional start of a service?


Gregory Gadow
12/5/2005 9:49:26 AM
I am writing a service using VB.NET 2.0. One of the first steps is to
retrieve some settings from the registry; I need the activation of the
service to halt if these settings are not found.

Looking at the generated code, it looks like I should do this
initialization in the Sub Main of the service, with a conditional call
to System.ServiceProcess.ServiceBase.Run. I assume that means I should
move all of my other initialization code like setting up the EventLog
reference, to the same location? I'm still kind of new to .NET
programming, so I'm wondering if there are any caveats to mucking with
generated code that Microsoft keeps hidden.
--
Gregory Gadow

John A. Bailo
12/5/2005 11:17:45 AM

Why not put it in the OnStart method?

[quoted text, click to view]
Gregory Gadow
12/6/2005 8:12:33 AM
[quoted text, click to view]

That seems to work. I do the checks in OnStart; if they fail then report to
the log and call Me.Stop. Thanks!

[quoted text, click to view]

--
Gregory Gadow

AddThis Social Bookmark Button