TCP Remoting Sample

To get samples and instructions for installing them, see the following:

  • Click Samples on the Visual Studio Help menu.

    For more information, see Locating Sample Files.

  • The most recent versions and the complete list of samples are available on the Visual Studio 2008 Samples Web site.

  • You can also locate samples on your computer's hard disk. By default, samples and a Readme file are copied to a folder under \Program Files\Visual Studio 9\Samples\. For Visual Studio Express Editions, all samples are located on the Internet.

To run this sample

  1. Build the RemoteCustomer project.

  2. Open the RemoteHost project and use F5 to start the RemoteHost application.

  3. Launch another instance of Visual Studio and load the Client project, and then add a reference to the compiled RemoteCustomer application (RemoteCustomer.dll).

  4. Use F5 to start the Client application.

  5. To test on two different computers, you will have to change the client's .config file, changing localhost to an IP address or DNS name for the server computer. In addition, you might have to change the server's file if you change the port number. See the comments in both the client's .config file and the host's .config file for examples.

Demonstrates

The sample contains three solutions, each with one project:

  • RemoteCustomer: the Server

  • RemoteHost: the Host

  • Client: the Client

RemoteCustomer

The RemoteCustomer is a class library that exposes three creatable types:

  • Customer (client activated)

  • SingleCallCustomer (WellKnown singlecall)

  • SingletonCustomer (WellKnown singleton)

Each class is located in the same namespace, RemotingSample, which is defined in each class source file.

RemoteHost

The RemoteHost project contains a Windows Forms application that will read an XML configuration file that is named Host.exe.config to make available the classes defined in the RemoteCustomer project. For a production application, you might want to host the class library (RemoteCustomer.dll) in a Windows service.

Client

The Client project is a Windows Forms application. It relies on a configuration file that is named Client.exe.config to know where to look for the remote objects.