Client-activated Remote Object Client Sample: Hosted in IIS

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 client-actived remote object hosted in IIS 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 client-activated remote object.  This project references a
	/// generated assembly called Test.dll.  The remote component is hosted in
	/// IIS.
	/// </summary>
	class Class1
	{
		/// 
		/// The main entry point for the application.
		/// 
		[STAThread]
		static void Main(string[] args)
		{
			Test.RemoteTest remoteTest = null;

			try
			{
				//Configure RemoteTest as a client-activated object 
				(hosted in IIS)
				RemotingConfiguration.Configure("RemoteTestClient.config");

				//Instantiate the remote object
				remoteTest = new Test.RemoteTest();

				//Prepare the remote object for stateful execution
				remoteTest.open();
				
				//Set the task inputs
				Test.TaskInput.TaskScreenInputs inputs = new Test.TaskInput.TaskScreenInputs();
				inputs.Input = "data";

				//Execute the task
				Test.TaskOutput.TaskScreenOutputs outputs = remoteTest.Task(inputs);

				//Display the output
				System.Console.WriteLine(outputs.Output);
			}
			catch (Exception xx)
			{
				System.Console.Error.WriteLine(xx);
			}
			finally
			{
				//Clean up
				remoteTest.close();
			}
		}
	}
}

Sample Configuration File for Client-activated RemoteTestClient.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.runtime.remoting>
<!-- Configuration for a client-activated RemoteTest object
 - hosted in IIS. -->
<application>
<client url="http://localhost/Test">
<activated type="Test.RemoteTest, Test"/>
</client>
<channels>
<channel ref="http">
<clientProviders>
<formatter ref="binary"/>
</clientProviders>
</channel>
</channels>
</application>
</system.runtime.remoting>
</configuration>

Related Topics
Bullet Using Tasks in Your Applications, Overview
Bullet Using .NET
  Attachmate