project : Class Library code at : MyRemotingClassEx using System; using System.Collections.Generic; using System.Text; namespace MyRemotingObjectEx { public class MyRemotingClassEx : MarshalByRefObject { public string GetRemoteString() { return ("Hello Hai This IS Lalitha"); } } } project : ConsoleApplication code at : MyServerAppEx Program.cs using System; using System.Collections.Generic; using System.Text; using System.Runtime.Remoting; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Channels.Tcp; namespace MyServerAppEx { class Program { static void Main(string[] args) { IChannel obj = new TcpChannel(8005); ChannelServices.RegisterChannel(obj,false); RemotingConfiguration.RegisterWellKnownServiceType(typeof(MyRemotingOb jectEx.MyRemotinClassEx),"myremotingobj",WellKnownObjectMode.Singleton); Console.WriteLine("Server IS Running"); Console.ReadLine(); }
}
} project : ConsoleApplication code at : MyProjectUsingRemoteObj Program.cs using System; using System.Collections.Generic; using System.Text; using System.Runtime.Remoting; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Channels.Tcp; namespace MyProjectUsingRemoteObj { class Program { static void Main(string[] args) { TcpClientChannel ch = new TcpClientChannel(); ChannelServices.RegisterChannel(ch, false);
RemotingConfiguration.RegisterWellKnownClientType(typeof(MyRemotingObj ectEx.MyRemotinClassEx),"tcp://localhost:8005/myremotingobj"); MyRemotingObjectEx.MyRemotinClassEx myobj = new MyRemotingObjectEx.MyRemotinClassEx(); Console.WriteLine(myobj.GetRemoteString()); } } }