Writing Our First Code
Now we need to modify the service so that it does something useful. Initially this will not be a major change, but later on we will be expanding the service.
In Visual Studio, click the Tutorials.vb tab and you will again see the <OnStart> and <OnStop> code. We will modify both methods to write an entry into the Application log.
This simple application demonstrates the process of creating a service in Visual Basic 2008; modifying the design template provided by Visual Studio 2008; and creating, building, and then installing the service.
Click the <OnStart> method. Under the comments section, we’ll first add an error handler:
Try Catch ex As Exception End Try
You should never leave your code unprotected from exceptions, especially ...
Get Programming Windows® Services with Microsoft® Visual Basic® 2008 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.