.NET Remote Client Object Sample Code: Server-activated Client

This sample is dependent on the successful implementation of a server-activated remote object. The sample consists of a simple console application that demonstrates how to execute a task via a server-activated remote object hosted in a custom application. Whenever a Web service or a remote object is generated, a configuration file is also created. Below is a sample of a custom host application using a server-activated remote object and a sample configuration file.

using System;
using System.Runtime.Remoting;

namespace CSharpClient
{
/// <summary>
/// A simple console application that demonstrates how to host a
/// server-activated remote object.  This application listens for
/// client requests on TCP port 8989.
/// </summary>
 class Class1
 {
  /// <summary>
  /// The main entry point for the application.
  /// </summary>
  [STAThread]
  static void Main(string[] args)
  {
    try
    {
      //Configure RemoteTestFactory as a server-activated object
      RemotingConfiguration.Configure("RemoteTestServer.config");

      //Wait for remote client requests
      Console.WriteLine("Listening for requests. Press Enter to exit...");
      Console.ReadLine();

    }
    catch (Exception xx)
    {
      Console.WriteLine(xx);
    }
			
  }
 }
}

Sample Configuration File: RemoteTestServer.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.runtime.remoting>
<application>        
<service>
<!-- Configuration for a server-activated RemoteTestFactory singleton-->
<wellknown mode="Singleton" type="Test.RemoteTestFactory, Test" objectUri="Test"/>
</service>
<channels>
<channel port="8989" ref="tcp">
<serverProviders>
<formatter ref="binary"/>
</serverProviders>
</channel>
</channels>
</application>
</system.runtime.remoting>
</configuration>
Related Topics
Bullet Using .NET
Bullet Adding .NET Remotable Objects to .NET Projects
Bullet .NET Deployment Examples
  Attachmate