This small Windows application shows how to make your application or part of it
be controlled from remote machines.
The demo application just can flip an image and this is also what several remote
clients can do.
Since most of the samples I found on Internet about remoting do let the .Net
runtime create the marshalled object in the hidden background,
I had to find a way to create and marshal my objects
programmatically to provide
it with a reference to my applications interface.
This is just what my application demonstrates.
It also demonstrates how to minimize the dependencies from server and clients by
accessing the remote object over interfaces.
Here is the design pattern for decoupling the objects with interfaces.
Using the code
The VS-Solution 'MyRemoteSampleApp.sln' holds the 3 projects: the
the client and the remotable class.
After starting 'MyServerApplication.exe' you can start as many clients
'MyClient.exe' as you like, which all connect to the same 'MyService' object.
Points of Interest
Create and marshal the object on server side in the applications '
TcpChannel channel = new TcpChannel(8080);
MyServiceClass remService = new MyServiceClass();
ObjRef obj = RemotingServices.Marshal(remService,"TcpService");
MainAppForm frmMain = new MainAppForm();
remService.theMainForm = ( IAppRemote) frmMain;
Connect to the remote object on client side:
IMyService remServive = null;
WellKnownClientTypeEntry remotetype = new WellKnownClientTypeEntry(
remServive = new MyServiceClass();