9.8. Windows Service Versus IIS

As it stands now, ServerInfo is hosted concurrently from a Windows Service and Internet Information Server. Each has its advantages. In terms of raw speed and configurability, nothing beats the Windows Service. On the other hand, any object derived from MarshalByRefObject takes only a few minutes to set up for remoting in IIS. However, this alone shouldn't determine which scenario is appropriate. After all, the server code in this chapter only requires the remote object to be in the same directory and have a <wellknown> entry in the configuration file, which takes about a minute for a fast typist.

The Windows Service can easily accommodate Singleton and SingleCall objects (as can IIS), but unlike IIS, it allows objects to be marshaled by value. Also, while both the service and IIS can use SAOs and CAOs, using CAOs from IIS is generally unwise. The ASP.NET worker process, which handles this process for IIS, can be recycled beyond a client's control, causing the CAO to be destroyed unexpectedly.

One of the most tangible benefits of using IIS over a Windows Service is security. There is also another option, XML web services, which is discussed in Chapter 10.

IIS also stands out in the client arena. Essentially, a remote object hosted under IIS is a web application managed by ASP.NET. Even though there are no visual elements (and the existing client runs in a console window), don't be fooled. Drop the ServerInfo.aspx file shown in Example ...

Get Object-Oriented Programming with Visual Basic .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.