// Reports that the method was called.
Console.WriteLine();
Console.WriteLine("Called HelloMethod on instance {0} with the '{1}' parameter.",
n_instance, name);
// Calculates and returns the result to the client.
return "Hi there " + name + ".";
}
}
服务器端ServerClass.cs
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Collections;
public class ServerClass
{
public static void Main()
{
try
{
TcpChannel [] TcpChannels = new TcpChannel[2];
for( int i =0;i<2;i++)
{
IDictionary props = new Hashtable();
props["name"] = "tcpChannel"+i.ToString();
props["port"] = 5000+i;
TcpChannel channel = new TcpChannel(
props,
null,
new BinaryServerFormatterSinkProvider()
);
ChannelServices.RegisterChannel(channel);