Windows Services
Download
Report
Transcript Windows Services
Windows Services
XML Web Services
Certification SIG
Tom Perkins
E-LEARNING XML WEB
SERVICES
Chapter 2, Lessons 1 - ?
Reference
• Windows Services: New Base Classes
in .NET Make Writing a Windows
Service Easy
• Ken Getz
• http://msdn.microsoft.com/msdnmag/is
sues/01/12/NETServ/
Windows Services
• Applications (executables - .exe)
• Run without user context
– Don’t have to be logged in to run
– no user interface
• Provide system-level support
– System event log
– Telephony
– Task scheduler
Windows Service Development
• Fairly easy in .NET; difficult in VB6 or
C++
• Create a Windows Service Project
– Takes care of details
• Creates a class that inherits from
ServiceProcess.ServiceBase class
Service you create
Can provide code for:
Service Control
• OnStart method
Manager (SCM)
• OnStop method
• OnPause method
• OnContinue method
• OnShutdown method
methods react to
requests
requests
other services
You interact
with the
service
through SCM
Installing the Service
• Service can’t install itself
• You must provide an installer class
– Inherits from Configuration.Install.Installer
• VS Project (for each service)
– Creates ServiceProcessInstaller object
• Knows how to install service with SCM
– Creates ServiceInstaller object
• Writes info re service to registry
Get Up and Running
•
•
•
•
Create the service project (class)
Compile .exe
Use InstallUtil to install
Control Panel Services applet
– Start the service
• Debug use the process containing the
service, step thru the code