Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger


Thursday 19 June 2008

.NET Windows services development questions

  1. Explain Windows service. You often need programs that run continuously in the background. For example, an email server is expected to listen continuously on a network port for incoming email messages, a print spooler is expected to listen continuously to print requests, and so on.
  2. What’s the Unix name for a Windows service equivalent? Daemon.
  3. So basically a Windows service application is just another executable? What’s different about a Windows service as compared to a regular application? Windows services must support the interface of the Service Control Manager (SCM). A Windows service must be installed in the Windows service database before it can be launched.
  4. How is development of a Windows service different from a Windows Forms application? A Windows service typically does not have a user interface, it supports a set of commands and can have a GUI that’s built later to allow for easier access to those commands.
  5. How do you give a Windows service specific permissions? Windows service always runs under someone’s identity. Can be System or Administrator account, but if you want to restrict the behavior of a Windows service, the best bet is to create a new user account, assign and deny necessary privileges to that account, and then associate the Windows service with that new account.
  6. Can you share processes between Windows services? Yes.
  7. Where’s Windows service database located? HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services
  8. What does SCM do? SCM is Windows Service Control Manager. Its responsibilities are as follows:
    • Accepts requests to install and uninstall Windows services from the Windows service database.
    • To start Windows services either on system startup or requested by the user.
    • To enumerate installed Windows services.
    • To maintain status information for currently running Windows services.
    • To transmits control messages (such as Start, Stop, Pause, and Continue) to available Windows services.
    • To lock/unlock Windows service database.
  9. vice on a box? Use Windows Service Installer, do not go through Add/Remove Programs or MSI file, as you would normally go with applications.
  10. When developing a Windows service for .NET, which namespace do you typically look in for required classes? System.ServiceProcess. The classes are ServiceBase, ServiceProcessInstaller, ServiceInstaller and ServiceController.
  11. How do you handle Start, Pause, Continue and Stop calls from SCM within your application? By implementing OnStart, OnPause, OnContinue and OnStop methods.
  12. Describe the start-up process for a Windows service. Main() is executed to create an instance of a Web service, then Run() to launch it, then OnStart() from within the instance is executed.
  13. I want to write a Windows service that cannot be paused, only started and stopped. How do I accomplish that? Set CanPauseAndContinue attribute to false.
  14. What application do you use to install a Windows service? installutil.exe
  15. I am trying to install my Windows service under NetworkService account, but keep getting an error. The LocalService and NetworkService accounts are only available on Windows XP and Windows Server 2003. These accounts do not exist on Windows 2000 or older operating systems.
  16. How can you see which services are running on a Windows box? Admin Tools -> Computer Management -> Services and Application -> Services. You can also open the Computer Management tool by right-clicking on My Computer and selecting Manage from the popup menu.
  17. How do you start, pause, continue or stop a Windows service off the command line? net start ServiceName, net pause ServiceName and so on. Also sc.exe provides a command-line interface for Windows services. View the OS documentation or proper book chapters on using sc.exe.
  18. Can I write an MMC snap-in for my Windows service? Yes, use classes from the System.Management.Instrumentation namespace. Also see Managing Applications Using WMI from .NET Framework SDK.

No comments:

Post a Comment