Skip to Content
Professional Visual Basic 2012 and .NET 4.5 Programming
book

Professional Visual Basic 2012 and .NET 4.5 Programming

by Bill Sheldon, Billy Hollis, Rob Windsor, David McCarter, Gastón Hillar, Todd Herman
January 2013
Intermediate to advanced
912 pages
26h 58m
English
Wrox
Content preview from Professional Visual Basic 2012 and .NET 4.5 Programming

Creating a Windows Service in Visual Basic

Here is a summary description of the necessary tasks to create a Windows Service. These tasks are demonstrated later in a detailed example:

1. Create a new project of the type Windows Service. By default, the service will be in a module named Service1.vb, but it can be renamed, like any other .NET module. The class automatically placed in Service1.vb is named Service1 by default, and it inherits from the ServiceBase class.
2. Place any logic that needs to run when the service is started in the OnStart event of the service class. You can find the code listing for the Service1.vb file by double-clicking this file's design surface.
3. Add any additional logic that the service needs to carry out its operation. Logic can be placed in the class for the service, or in any other class module in the project. Such logic is typically called via some event that is generated by the operating system and passed to the service, such as a file changing in a directory, or a timer tick.
4. Add an installer to the project. This module provides the interface to the Windows operating system to install the module as a Windows Service. The installer is a class that inherits from System.Configuration.Install.Installer, and it contains instances of the ServiceProcessInstaller and ServiceInstaller classes.
5. Set the properties of the installer modules as necessary. The most common settings needed are the account under which the service will run and the name ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Visual Basic 2012 Programmer's Reference

Visual Basic 2012 Programmer's Reference

Rod Stephens

Publisher Resources

ISBN: 9781118332139Purchase book