C# – Confusion in .net Remoting

cnetremoting

I am studying .net Remoting

I've read from MSDN, but in one step I am facing some confusion..

Three steps are required for remoting purpose.

1 – RemoteObject

2 – Host

3 – Client

creating RemoteObject and Host is fine. I understand all the things, it uses Configuration File for both Host and Client Configuration. In Client it uses the following code

public static void Main(){
      RemotingConfiguration.Configure("Client.exe.config");
      RemotableType remoteObject = new RemotableType();
      Console.WriteLine(remoteObject.SayHello());
   }

Here it is creating Object of RemotableType with new operator. Where as this Client application has reference of RemotableType.dll.

When this dll is available locally then what is the purpose of calling SayHello() remotely?

I ran this client without running server and it still displays me Hello World message.

Is this creation of remoteObject with new operator is valid here?

Where as the other method of getting remoteobject is:

RObject remoteObject = (RObject)Activator.GetObject(typeof(RObject), "tcp://localhost:9999/RObject");

Best Answer

Usually you will create two DLLs: One that contains an interface definitions for your remotable object and another one that contains the implementation of the interface definitions.

You will then add the interface definition DLL to the client, while the server needs both DLLs. The client will then create instances of the class using the Activator.GetObject(...) call.

If you reference the implementation DLL from your client - as you pointed out - you do not have any advantages from the client/server implementation.