Business web hosting - CHAPTER 18 598 THE .NET REMOTING LAYER
CHAPTER 18 598 THE .NET REMOTING LAYER Figure 18-7. Creating a new Windows Service project workspace As luck would have it, building a custom Windows service using the .NET platform is extremely simple when contrasted to the raw Win32 API. To illustrate, let s create aWindows Service project named CarWinService (see Figure 18-7) that will be in charge of hosting the remote types contained within the CarGeneralAsm.dll. Visual Studio 2005 responds by generating a partial class (named Service1 by default), which derives from System.ServiceProcess.ServiceBase, and another class (Program), which implements the service s Main() method. Given that Service1 is a rather nondescript name for your custom service, the first order of business is to change the values of the (Name) and ServiceName properties to CarService using the IDE s Properties window. The distinction between these two settings is that the (Name) value is used to define the name used to refer to your type in the code base, while the ServiceName property marks the name to display to Windows service centric configuration tools. Before moving on, be sure you set a reference to the CarGeneralAsm.dll and System.Remoting. dll assemblies, and specify the following additional using directives to the file containing the CarService class definition: using System.Runtime.Remoting; using System.Runtime.Remoting.Channels.Http; using System.Runtime.Remoting.Channels; using System.Diagnostics; Implementing the Main() Method The Main() method of the Program class is in charge of running each service defined in the project by passing an array of ServiceBase types into the static Service.Run() method. Given that you have renamed your custom service from Service1 to CarService, you should find the following class definition (comments deleted for clarity):
From our experience, we can recommend PHP Web Hosting services, if you need affordable webhost to host and run your web application.