9.8 Windows Service Versus IIS

only for RuBoard

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 9-14 into the ServerInfo directory.

Example 9-14. ServerInfo.aspx
 <%@ Page Language="VB" %> <%@ Import Namespace="ObjectServerSpace" %>     <html> <head>   <script language="VB" runat="server">     Sub Page_Load(ByVal obj As Object, ByVal e As EventArgs)       Dim si As New ServerInfo( )       machine.Text = si.MachineName.ToUpper       ip.Text = si.IPAddress.ToString       dt.Text = si.GetMachineTime       freeMem.Text = si.GetAvailableMemory.ToString + "MB Free"       procUsed.Text = "Processor Used: " + _         si.GetProcessorUsed.ToString + "%"     End Sub   </script> </head> <body> <form runat="server">   <asp:label id="machine" runat="server"      style="font-size: 14pt;"/></br>   <asp:label id="ip" runat="server"/></br>   <asp:label id="dt" runat="server"/></br>   <asp:label id="freemem" runat="server"/></br>   <asp:label id="procUsed" runat="server"/></br> </form> </body> </html> 

Once in place, the page (shown in Figure 9-4) can be hit from the following URL using any browser: .

Figure 9-4. Using a browser with remote objects hosted in IIS
only for RuBoard

Object-Oriented Programming with Visual Basic. Net
Object-Oriented Programming with Visual Basic .NET
ISBN: 0596001460
EAN: 2147483647
Year: 2001
Pages: 112
Authors: J.P. Hamilton

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