Server-activated Remote Object Client Sample: 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 simple task execution using a server-actived remote object hosted in a custom application and a sample configuration file.

using System;
using System.Runtime.Remoting;

namespace CSharpClient
	/// <summary>
	/// A simple console application that demonstrates how to execute a task
	/// via a server-activated remote singleton.  This project references
	/// a generated assembly called Test.dll.  The remote component is hosted
	/// in a custom application that listens on TCP port 8989.
	/// </summary>
	class Class1
		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		static void Main(string[] args)
			Test.RemoteTest remoteTest = null;

				//Configure RemoteTestFactory as a server-activated object

				//Use the remote factory to instantiate RemoteTest
				remoteTest = new Test.RemoteTestFactory().createRemoteTest();

				//Prepare the remote object for stateful execution;
				//Set the task inputs
				Test.Task1Input.Task1ScreenInputs inputs = new Test.Task1Input.Task1ScreenInputs();
				inputs.Input1 = "data";

				//Execute the task
				Test.Task1Output.Task1ScreenOutputs outputs = remoteTest.Task1(inputs);

				//Display the output
			catch (Exception xx)
				//Clean up

Sample Configuration File for Server-activated RemoteTestClient.config

<?xml version="1.0" encoding="UTF-8"?>
<!-- Configuration for a server-activated RemoteTestFactory singleton
 - hosted in a custom application. -->
<wellknown type="Test.RemoteTestFactory, Test" url="tcp://localhost:8989/Test"/>
<channel ref="tcp">
<formatter ref="binary"/>
Related Topics
Bullet Using Tasks in Your Applications, Overview
Bullet Using .NET