|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
IntroductionWhy am I publishing this sample? Because it is very difficult to find working code in the MSDN or internet. Most samples require awkward config files or they are much too complicated for beginners. This sample runs immediately and does not require config files. The original intention was to remote control an application on a slave computer via network. The master sends a command and waits for the slave until it executes the remote command. This sample sends only text strings, but it can easily be expanded to transfer anything. (See class Features
How does it work?
Programming .NET RemotingThere a three major ways to use .NET Remoting (this sample uses the first one): Publishing a public object(Object is created locally and then published.) Host:ChannelServices.RegisterChannel (new TcpChannel(1500));
cTransfer Trans = new cTransfer();
RemotingServices.Marshal (Trans, "TestService");
Client:cTransfer T = (cTransfer) Activator.GetObject(typeof(cTransfer),
"tcp://host:1500/TestService");
Remote creation of a public object (SAO)(Object is created on request of client) Host:ChannelServices.RegisterChannel (new TcpChannel(1500));
RemotingConfiguration.RegisterWellKnownServiceType(typeof(cTransfer),
"TestService", WellKnownObjectMode.Singleton);
Client:cTransfer T = (cTransfer) Activator.GetObject(typeof(cTransfer),
"tcp://host:1500/TestService");
Remote creation of a private object (CAO)(Object is created on host and client receives a reference to it) Host:ChannelServices.RegisterChannel (new TcpChannel(1500));
RemotingConfiguration.RegisterActivatedServiceType(typeof(cTransfer));
Client:object[] attr = {new UrlAttribute("tcp://host:1500")};
object[] args = {"Sample constructor argument"};
cTransfer T = (cTransfer) Activator.CreateInstance(typeof(cTransfer), args, attr);
Notes:
This should be enough of explanation. Look into the source code: it's really simple!
|
||||||||||||||||||||||