.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
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
try
{
RemotingConfiguration.Configure("RemoteTestServer.config");
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>
<wellknown mode="Singleton" type="AMNUtask.RemoteTestFactory, AMNUtask" objectUri="AMNUtask"/>
</service>
<channels>
<channel port="8989" ref="tcp">
<serverProviders>
<formatter ref="binary"/>
</serverProviders>
</channel>
</channels>
</application>
</system.runtime.remoting>
</configuration>