As shown in the previous sections, the remote object must be hosted by some server application. Listing 39.5 showed the code necessary to build a bare-bones hosting application. That was fairly simple, but an application has already been written that can do this for you. Internet Information Services (IIS) is an application that comes with Windows and is quite capable of hosting the remote object for you with minor changes to the application. The first change is that you must tell IIS where your object is located and how to host the remote object. You accomplish this through the use of a virtual directory and web.config file. To better illustrate this, follow these steps:
Create a directory called SampleService in the Inetpub\wwwroot directory.
Under the SampleService directory, create a subdirectory named bin.
On your local machine, create a virtual directory called SAMSSampleService and point it to the SampleService directory you created in step 1. You can use all the defaults when creating the virtual directory.
Cut and paste the code in Listing 39.6
into a file named web.config
and save that file in the SampleService
Copy the Chapter41Common.dll file from the build directory to the SampleService\bin directory.
Modify the shaded code in Listing 39.5
by removing the port designation (http://localhost:9000
should become http://localhost
Build and run the client application.
After the application has been built and run, you should see the same results as you did by running the server and the client.