The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

TCP Remoting Sample

This sample shows how to use the .NET Framework remoting architecture. In addition, it uses XML configuration files to specify available objects and server location information instead of hard-coding them into the binaries or putting the data into the system registry.

To get samples and instructions for installing them

  • Do one or more of the following:

    • On the Help menu, click Samples.

      The Readme displays information about samples.

    • Visit the Visual Studio 2008 Samples Web site. The most recent versions of samples are available there.

    • Locate samples on the computer on which Visual Studio is installed. By default, samples and a Readme file are installed in drive:\Program Files\Microsoft Visual Studio 9.0\Samples\lcid. For Express editions of Visual Studio, all samples are located online.

For more information, see Visual Studio Samples.

Security noteSecurity Note:

This sample code is intended to illustrate a concept, and it shows only the code that is relevant to that concept. It may not meet the security requirements for a specific environment, and it should not be used exactly as shown. We recommend that you add security and error-handling code to make your projects more secure and robust. Microsoft provides this sample code "AS IS" with no warranties.

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.

The sample contains three solutions, each with one project:

  • RemoteCustomer: the Server

  • RemoteHost: the Host

  • Client: the Client

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.

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.

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.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2015 Microsoft