.NET Windows Services & Design Patterns
This quiz tests knowledge of Windows Services architecture in .NET and fundamental software design patterns including Observer, Chain of Responsibility, Decorator, and Factory patterns.
Questions
Which class does a Windows service always inherit from?
- System.ServiceProcess.ServiceInstaller
- System.ServiceProcess.ServiceController
- System.ServiceProcess.ServiceBase
- System.ServiceProcess.ServiceProcessInstaller
You want to create a Windows service that will monitor specific folders on the hard drive. This service won't be shared with any other process and will launch when the system is booted. Which configuration would be appropriate for this particular service?
- Win32OwnProcess type, Network Service account, automatic startup type
- Win32OwnProcess type, LocalSystem account, automatic startup type
- Win32OwnProcess type, User account, manual startup type
- All
Which of the following classes handles the service account type?
- ServiceBase
- ServiceController
- ServiceProcessInstaller
- ServiceInstaller
Your application is set to start automatically - you stop it using the SCM and restart it. Which sequence of events is triggered from the time the machine is booted?
- OnPause, OnStop, OnStart
- OnStart, OnStop, OnStart
- OnStop, OnContinue
- OnStop, OnStart
You need to create a source for this service. Which command completes the code? //Add any initialization after the InitializeComponent() callif (!FMEventLog.SourceExists("FileMonitorWS") { FMEventLog. MISSING CODE ("FileMonitorWS", "FMEventLog")}FMEventLog.Source = "FileWS";FMEEventLog.Log = "FMEventLog";
- BuildEventSource
- CreateEventSource
- CallEventSource
- All
Which switch do you use with the installutil command to uninstall an assembly?
- /delete
- /remove
- /u
- /uninstall
Why would you choose to create a setup project to install your service?
- Service components are spread over several servers
- The service uses unmanaged code
- You have been unable to install the service manually
- You want to distribute the service
Which hive of the Registry is used by Windows Services to store their properties?
- HKEY_CURRENT_CONFIG
- HKEY_CURRENT_USER
- HKEY_LOCAL_MACHINE
- HKEY_USERS
What property name should be added to this code snippet to allow a service to resume after pausing? if (FMServiceController.MISSING CODE) FMServiceController.Continue(); else MessageBox.Show("Service cannot be continued.");
- CanContinue
- CanPauseAndContinue
- CanResume
- Continue
By default, services run in a different security context than that of the logged-in user. Which account types can be specified for a Windows Service?
- LocalService
- LocalSystem
- Administrator
- NetworkService
- User
Which can you use to install a Windows Service?
- The installutil command
- The Service Control Manager
- The Windows Registry
- Windows Installer file (.msi)
What actions can you accomplish using the Services Control Manager?
- Changing service descriptions
- Creating service installation projects
- Starting and stopping services
- Uninstalling services
Suppose you were programmatically creating a component to control the FileWatch service on a local EasyNomad machine. Which options are correct?
- private ServiceController FMServiceController = new ServiceController ('EasyNomad') ;
- private ServiceController FMServiceController = new ServiceController ('EasyNomad', 'FileWatch') ;
- private ServiceController FMServiceController = new ServiceController ('FileWatch', 'EasyNomad') ;
- private ServiceController FMServiceController = new ServiceController(“FileWatch”) ;
What are the ways of creating a ServiceController component instance?
- Adding the ServiceController component from the Services Control Manager
- Adding the ServiceController component from the Toolbox
- Adding the ServiceController component to the Designer from Server Explorer
- Using manually entered code
Which of these steps are required to debug an entire Windows service?
- Attaching the debugger to the service process
- Creating a dummy service to call the service
- Starting a dummy service
- Starting both services
What properties would you set to True for a service that can restart after being paused and which writes information to the Application log?
- CanShutDown
- CanPauseAndContinue
- AutoLog
- CanStop
Provides a simple decision making class which returns one of several possible subclasses of an abstract base class depending on data it is provided
- Factory Pattern
- Abstract Factory Pattern
- Builder Pattern
- Prototype Pattern
A class that surrounds a given class, adds new capabilities to it, and passes all the unchanged methods to the underlying class
- Flyweight Pattern
- Façade Pattern
- Composite Pattern
- Decorator Pattern
This pattern allows decoupling between classes, by passing a request between classes until it is recognized
- Adapter Pattern
- Observer Pattern
- Chain of Responsibility Pattern
- Strategy Pattern
Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically
- Visitor Pattern
- Notifier Pattern
- Observer Pattern
- Template Pattern