Friday, August 29, 2008

.Net Remoting

//>> The Programming Interface
//using System.
// >> Remoting

// The Server End
public class Server
{
public void Start()
{
TcpChannel channel = new TcpChannel();
ChannelServer.RegisterChannel(channel);
RemotingConfiguration.RegisterWellKnownServiceType(
typeof(ServiceType),
"ServiceMethodUri",
WellknownObjectMode.Singleton // or SingleCall
);
}
}

//>> The Client End
public class Client
{
public void ConsumeRemoting()
{
TcpChannel channel = new TcpChannel();
ChannelService.RegisterChannel(channel);
try
{
ServiceType serviceObject = (ServiceType)Activator.GetObject(ServiceType, "tcp://127.0.0.1:4000/HelloDotNet");
serviceObject.SayHello();
}
catch
{
}
}
}

No comments: