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

A simple console application that demonstrates how to host a server-activated remote object. This application listens for client requests on TCP port 8989. 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;

// NOTE: Add project reference to AMNUtask.DLL
// 1. Project \ Add Reference... menu item
// 2. Use Browse button to find and add DLL.
using AMNUtask;

namespace AMNUtaskRemote
  /// <summary>
  /// Summary description for Class1.
  /// </summary>
  class Class1
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    static void Main(string[] args)
      AMNUtask.RemoteAMNUtask remoteAMNUtask = null;

        //Configure RemoteAMNUtask as a server-activated object
        RemotingConfiguration.Configure("C:\\Program Files\\Attachmate\\EAI\\CICSClient\\samples\\AMNU\\remote\\AMNUtaskRemote\\RemoteAMNUtaskClient.config");

        //Instantiate the remote object
        remoteAMNUtask = new AMNUtask.RemoteAMNUtaskFactory().createRemoteAMNUtask();

        //Prepare the remote object for stateless execution
        //Set the task inputs
        AMNUtask.AMNUInput.input input = new AMNUtask.AMNUInput.input();

        input.CICSUserInfo = new AMNUtask.AMNUInput.input_CICSUserInfo();
        input.CICSUserInfo.USER_ID = "USERID";
        input.CICSUserInfo.PASSWORD = "PW";

        input.FILE_XACT = new AMNUtask.AMNUInput.input_FILE_XACT();
        input.FILE_XACT.COMMCODE = "2";
        input.FILE_XACT.FILENAME = "FILEA";
        input.FILE_XACT.REC_KEY_FLD = "000102";

        //Execute the task
        AMNUtask.AMNUOutput.output output = remoteAMNUtask.AMNU(input);

        //Display the output
        System.Console.WriteLine("NAME: " + output.FILE_XACT.FILEREC.NAME);
      catch (Exception xx)
        //Clean up
        if (remoteAMNUtask != null)

Sample Configuration File: RemoteAMNUClient.config

<?xml version="1.0" encoding="UTF-8"?>
<!-- Configuration for a server-activated RemoteAMNUtaskFactory singleton
 - hosted in a custom application.-->
<wellknown type="AMNUtask.RemoteAMNUtaskFactory, AMNUtask" url="tcp://localhost:8989/AMNUtask"/>
<channel ref="tcp">
<formatter ref="binary"/>
Related Topics
Bullet Using .NET
Bullet Adding .NET Remotable Objects to .NET Projects
Bullet .NET Deployment Examples