tailieunhanh - Pro VB 2005 and the .NET 2.0 Platform Second Edition phần 7

Bạn có thể rất có thể đã giả định những gì sắp xếp logic xảy ra khi tùy chỉnh dịch vụ của bạn là bắt đầu trên một máy nhất định. Nhớ lại rằng vai trò của CarService là để thực hiện các nhiệm vụ tương tự như dịch vụ của bạn tùy chỉnh giao diện điều khiển dựa trên. | 606 CHAPTER 20 THE .NET REMOTING LAYER Implementing You can likely already assume what sort of logic should happen when your custom service is started on a given machine. Recall that the role of CarService is to perform the same tasks as your custom console-based service. Thus if you wish to register CarService as a WKO-singleton type that is available via HTTP you could add the following code to the OnStart method of course you could also choose to dynamically read the remoting information from a .config file Protected Overrides Sub OnStart ByVal args As String Create a new HttpChannel. Dim c As HttpChannel New HttpChannel 32469 c False Register as single-call WKO. _ GetType _ _ End Sub Technically speaking the CarService does not demand any sort of shutdown logic. Therefore for this example we can leave the OnStop method implementation empty. Now that the service is complete the next task is to install this service on the target machine. Adding a Service Installer Before you can install your service on a given machine you need to add an additional type into your current CarWinService project. Specifically any Windows service written using .NET or the Win32 API requires a number of registry entries to be made to allow the OS to interact with the service itself. Rather than making these entries manually you can simply add an Installer type to a Windows service project which will configure your ServiceBase-derived type correctly when installed on the target machine. To add an installer for the CarService open the design-time service editor by double-clicking the file from Solution Explorer right-click anywhere within the designer and select Add Installer see Figure 20-9 . Figure 20-9. Including an installer for the custom Windows service CHAPTER 20 THE .NET REMOTING LAYER 607 .

TỪ KHÓA LIÊN QUAN