C# Remote Client Object

The client application in C# for invoking methods on remote objects follows a straightforward process. The .NET Remoting System acts as an intermediary, intercepting client calls and routing them to the remote object, facilitating communication and returning the results to the client. Additionally, the client application needs to register for the remote type to establish the necessary connection and interaction with the remote object. This seamless integration between the client application and the remote object allows for efficient and effective communication within the remoting framework.

Client Application

In the C# client application, an instance of the remote type, specifically the RemoteTime object, is created to facilitate the invocation of the desired method, getTime(). The client application further utilizes the configuration file Client.exe.config, which contains the necessary communication information for seamless interaction with the Remoting Framework. By leveraging these components, the client application successfully establishes the connection and communication with the remote object, enabling the retrieval of the desired information or execution of the specified functionality.

Full Source C#
using System; using System.Runtime.Remoting; public class Client { public static void Main() { RemotingConfiguration.Configure("Client.exe.config"); RemoteTime remoteTimeObject = new RemoteTime(); Console.WriteLine(remoteTimeObject.getTime()); } }

Copy and paste the above C# source code into a file and save it as Client.cs .

In order to supply the necessary communication information to the client object, it is imperative to create an additional configuration file. This configuration file, structured in XML format, allows for the specification of various parameters such as the remote type, channel settings, communication port, and more. By utilizing this configuration file, we can effectively configure and customize the communication aspects of the client object, facilitating smooth and reliable communication within the application.


Click here to download Client.exe.config

Compile the class file Client.cs using the command-line tools that ship with the Visual Studio SDK .

At the command prompt type the following command:

csc /r:RemoteTime.dll Client.cs

After you compile the Client.cs , you will get a file called Client.exe in the directory where your compiler resides.

If your file Client.cs and RemoteTime.dll is residing in c:\src then you should type command like the following :

csc /r:c:\src\RemoteTime.dll c:\src\Client.cs