// Collection of code snippets by Arne Vajhøj // (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) using System; using System.Runtime.Remoting; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Channels.Tcp; using Remoting.Common; namespace Remoting.Server { public class Test : MarshalByRefObject, ITest { private int counter; public int Add(int a, int b) { return a + b; } public String Dup(String s) { return s + s; } public Data Process(Data d) { return new Data(d.Iv + 1, d.Sv + "X"); } public int GetCounter() { counter++; return counter; } public void Noop() { // nothing } } public class Program { private const int SERVER_PORT = 12345; private const string NAME1 = "Test1"; private const string NAME2 = "Test2"; public static void Main(string[] args) { ChannelServices.RegisterChannel(new TcpServerChannel(SERVER_PORT), false); RemotingConfiguration.RegisterWellKnownServiceType(typeof(Test), NAME1, WellKnownObjectMode.Singleton); RemotingConfiguration.RegisterWellKnownServiceType(typeof(Test), NAME2, WellKnownObjectMode.SingleCall); Console.ReadKey(); } } }