O'Reilly logo

Programming Windows® Services with Microsoft® Visual Basic® 2008 by Michael Gernaey

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required