Review Questions

1. 

How can you best describe a Windows service application?

  1. It impersonates the identity of the user who is logged in.

  2. It runs in its own process with its own security account.

  3. It runs in the same process space as the web server with the identity of IUSR_Machine.

  4. It runs in the same process space as the operating system and must have Administrator privileges.

ba windows service runs in its own memory process space and has its own security account, most commonly localsystem. a windows service does not interfere with other users or programs running on the computer.

2. 

Windows services begin running:

  1. When the computer is booted, if the Startup type is set to Automatic

  2. When a user logs in

  3. Only when an Administrator starts them

  4. Only when called by a ServiceController object

aif the service s startuptype property is set to automatic, the service will be started when the computer is started or rebooted. if the startuptype property is set to manual, then the service must be started by using either the service control manager console or by application code that uses a servicecontroller object.

3. 

How can you view information about the services running on a specific computer?

  1. By using the Server Explorer in Visual Studio .NET

  2. By using a method of the ServiceController class

  3. By using the Windows Service Control Manager console

  4. All of the above

dyou can view information about windows services by using either the windows service control manager console or the visual studio .net server explorer. the getservices and getdevices methods of the servicecontroller class also provide information about the services that are running on a specific computer.

4. 

Your Windows service needs to read some default values from a disk file every time it is started. How can you accomplish this?

  1. Write code in the OnStart method of your service application.

  2. Write code in the OnCustomCommand method of your service application.

  3. Write code in the Sub Main method of your service application.

  4. Write code in the Sub New method of your service application.

athe onstart method is the recommended place to put code that should run when a service is started. code in the constructor, sub new , might not run when a service is stopped and restarted.

5. 

All Windows service applications support the same basic interface, because:

  1. The operating system will not load them if they do not implement all standard methods.

  2. They will not compile if they do not implement all standard methods.

  3. They all inherit from the System.ServiceProcess.ServiceInstaller class.

  4. They all inherit from the System.ServiceProcess.ServiceBase class.

dto create an application that will run as a windows service in visual studio .net, you must inherit base class functionality from the system.serviceprocess.servicebase class.

6. 

If you leave the AutoLog property set to the default value of True in your Windows service. what behavior will you see when the service is running?

  1. Stop, Start, Pause, and Continue events will be written to a custom event log with the same name as your service.

  2. Stop, Start, Pause, and Continue events will be written to the Windows Application event log.

  3. No logging will take place unless you set the EventLog property to the name of a custom event log.

  4. No logging will take place unless you write code in the OnStart method to write entries to a custom event log.

bif the autolog property of a windows service application is set to true, stop , start , pause , and continue events will be written to the windows application event log without any further coding necessary.

7. 

You create a Windows service project that includes two Windows services. When you add installer components to your project, how many objects will be added?

  1. One ServiceInstaller object

  2. One ServiceInstaller object and one ServiceProcessInstaller object

  3. One ServiceInstaller object and two ServiceProcessInstaller objects

  4. Two ServiceInstaller objects and two ServiceProcessInstaller objects

ca windows service project in visual studio .net can contain more than one windows service component class module. when you add installers to the project, one serviceinstaller object will be added, and one serviceprocessinstaller object will be added for each windows service module contained in the project.

8. 

You need to specify the security account that your Windows service will run under. How can you specify this while creating the project in Visual Studio .NET?

  1. Set the Account property of the ServiceBase class.

  2. Set the Account property of the ServiceProcessInstaller object.

  3. Set the Account property of the ServiceInstaller object.

  4. Change the Account setting in the Project Properties dialog box.

buse the account property of the serviceprocessinstaller object to specify which security account the service should run under.

9. 

What is the most commonly used security account for running Windows services?

  1. Interactive User

  2. LocalSystem

  3. Administrator

  4. NetworkService

blocalsystem is currently the most commonly used security account for running windows service applications. it is a highly privileged account, which can pose a security risk. the new windows xp accounts, networkservice and localservice, might be better choices from a security standpoint.

10. 

You have created a Windows service application and you would like to use the debugging tools in Visual Studio .NET to troubleshoot a problem with the application. You load the application in Visual Studio .NET. What should you do next?

  1. Select Debug Ø Start from the Visual Studio .NET menu.

  2. Select Debug Ø Step Into from the Visual Studio .NET menu.

  3. Select Debug Ø Processes from the Visual Studio .NET menu.

  4. Select Debug Ø Exceptions from the Visual Studio .NET menu.

cto debug a windows service application, you must install and run it. after it is running, you can attach the visual studio .net debugger to this external process. use the debug processes menu choice to display the processes dialog box to choose from all running processes on the computer.

11. 

You need to create an application that is able programmatically to start and stop a Windows service. Which .NET Framework class should you use?

  1. System.ServiceProcess.ServiceBase

  2. System.ServiceProcess.ServiceController

  3. System.ServiceProcess.ServiceInstaller

  4. System.ServiceProcess.Status

bthe system.serviceprocess.servicecontroller .net framework class has properties and methods that enable you to get information about a windows service and to control the service through application code.

12. 

You are creating an application that controls a Windows service programmatically. You would like to be able to call the Pause method to temporarily disable the service while your application is running, but this does not seem to be working. What can you do to overcome this problem?

  1. You must set the CanPauseAndContinue property of the ServiceController to True before you can call the Pause method.

  2. You must set the CanStop property of the ServiceController to True before you can call the Pause method.

  3. Nothing. You cannot use the Pause method if the original designer of the Windows service did not set the CanShutdown property to True.

  4. Nothing. You cannot use the Pause method if the original designer of the Windows service did not set the CanPauseAndContinue property of the ServiceBase class to True.

dthe original creator of the windows service application sets the canstop and canpauseandcontinue properties of the service. the original designer might not want the service to be stopped or paused by a user, as is often the case with operating system services.

13. 

You have created an application that is able to programmatically start and stop a Windows service. However, after using the Start method, your application always reports back that the service’s status is StartPending rather than the Running status that you are looking for. How can you be sure that the service has successfully been started and is running, before your application takes any further action?

  1. Use the GetService method and see whether your service is included in the array of services that is returned.

  2. Set a Timer control to call the Refresh method until a status of Running is returned.

  3. Use the WaitforStatus method with ServiceControllerStatus.Running as the parameter.

  4. Use the ExecuteCommand method to run custom code when the service starts.

cthe waitforstatus method of the servicecontroller class will cause application code to block until the desired status is reached.

14. 

You need to create an application that is able to programmatically execute custom commands of a Windows service. How do you call custom commands from your application?

  1. Use the ServiceBase class OnCustomCommand method and pass an integer parameter.

  2. Use the ServiceController class OnCustomCommand method and pass a string parameter.

  3. Use the ServiceBase class ExecuteCommand method and pass a string parameter.

  4. Use the ServiceController class ExecuteCommand method and pass an integer parameter.

dto call a custom command from an application that can control windows services programmatically, use the servicecontroller.executecommand method. this method takes a single integer parameter, which indicates the command that the user would like to run. valid parameter values are defined by the designer of the windows service application (within the range of 128 to 256).

15. 

What does the OnPowerEvent method of the ServiceBase class do?

  1. Enables the designer of the Windows service to write code that will run in the event of a power outage

  2. Enables the designer of the Windows service to write code that will run when the computer shuts down

  3. Enables the designer of the Windows service to write code that will run when a laptop computer goes into suspended mode.

  4. Enables the designer of the Windows service to write code that will run when a custom command is executed

cthe onpowerevent method is intended to be used if your service must run on laptop computers. you might want to save data, for example, before the computer goes into suspended mode.

Answers

1. 

B A Windows service runs in its own memory process space and has its own security account, most commonly LocalSystem. A Windows service does not interfere with other users or programs running on the computer.

2. 

A If the service’s StartUpType property is set to Automatic, the service will be started when the computer is started or rebooted. If the StartUpType property is set to Manual, then the service must be started by using either the Service Control Manager console or by application code that uses a ServiceController object.

3. 

D You can view information about Windows services by using either the Windows Service Control Manager console or the Visual Studio .NET Server Explorer. The GetServices and GetDevices methods of the ServiceController class also provide information about the services that are running on a specific computer.

4. 

A The OnStart method is the recommended place to put code that should run when a service is started. Code in the constructor, Sub New, might not run when a service is stopped and restarted.

5. 

D To create an application that will run as a Windows service in Visual Studio .NET, you must inherit base class functionality from the System.ServiceProcess.ServiceBase class.

6. 

B If the AutoLog property of a Windows service application is set to True, Stop, Start, Pause, and Continue events will be written to the Windows Application event log without any further coding necessary.

7. 

C A Windows service project in Visual Studio .NET can contain more than one Windows service component class module. When you add installers to the project, one ServiceInstaller object will be added, and one ServiceProcessInstaller object will be added for each Windows service module contained in the project.

8. 

B Use the Account property of the ServiceProcessInstaller object to specify which security account the service should run under.

9. 

B LocalSystem is currently the most commonly used security account for running Windows service applications. It is a highly privileged account, which can pose a security risk. The new Windows XP accounts, NetworkService and LocalService, might be better choices from a security standpoint.

10. 

C To debug a Windows service application, you must install and run it. After it is running, you can attach the Visual Studio .NET debugger to this external process. Use the Debug Ø Processes menu choice to display the Processes dialog box to choose from all running processes on the computer.

11. 

B The System.ServiceProcess.ServiceController .NET Framework class has properties and methods that enable you to get information about a Windows service and to control the service through application code.

12. 

D The original creator of the Windows service application sets the CanStop and CanPauseAndContinue properties of the service. The original designer might not want the service to be stopped or paused by a user, as is often the case with operating system services.

13. 

C The WaitforStatus method of the ServiceController class will cause application code to block until the desired status is reached.

14. 

D To call a custom command from an application that can control Windows services programmatically, use the ServiceController.ExecuteCommand method. This method takes a single integer parameter, which indicates the command that the user would like to run. Valid parameter values are defined by the designer of the Windows service application (within the range of 128 to 256).

15. 

C The OnPowerEvent method is intended to be used if your service must run on laptop computers. You might want to save data, for example, before the computer goes into suspended mode.



MCAD/MCSD(c) Visual Basic. NET XML Web Services and Server Components Study Guide
MCAD/MCSD: Visual Basic .NET XML Web Services and Server Components Study Guide
ISBN: 0782141935
EAN: 2147483647
Year: 2005
Pages: 153

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net