using System;
using System.Collections;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
namespace CodeGuru.RemotingSample
{
/// <remarks>
/// Sample client to demonstrate the use of secure .NET Remoting.
/// </remarks>
public class SampleRemotingClient
{
public static void Main()
{
// Setup the configuration parameters through a dictionary
IDictionary properties = new Hashtable();
properties.Add("secure", true);
properties.Add("connectionTimeout", 5000);
properties.Add("tokenImpersonationLevel", "Impersonation");
// Create a channel for communicating w/ the remote object
TcpClientChannel clientChannel =
new TcpClientChannel(properties, null);
ChannelServices.RegisterChannel(clientChannel, true);
// Create an instance of the remote object
RemotingConfiguration.RegisterWellKnownClientType(
typeof(SampleObject),
"Tcp://MyServerName:9977/HelloWorldUri");
SampleObject sample = new SampleObject();
Console.WriteLine("{0}", sample.HelloWorld());
Console.WriteLine("Press the enter key to exit...");
Console.ReadLine();
}
}
}