We already created a Remote Type Object C# Remotable Object in the previous section. We have to create a listener Object for enable Objects in other application domains to create instances of this object ( RemoteTime ) Remotely. When creating a listener Object we have to choose and register a channel for handle the networking protocol and serialization formats and register the Type with the .NET Remoting System , so that it can use the channel to listen for requests for the Type. C# Remote Channels are Objects that responsible of handling the network protocols and serialization formats.
In the following C# source code we are creating a listener application TimeListener.cs . It will act as a listener Object for the Remote Type RemoteTime. The Listener class TimeListener must be able to find the TimeListener.exe.config file to load the configuration for the RemotableType class.
using System;
using System.Runtime.Remoting;
public class TimeListener
{
public static void Main()
{
RemotingConfiguration.Configure("TimeListener.exe.config");
Console.WriteLine("Listening for requests from the Client! Press Enter to exit...");
Console.ReadLine();
}
}csc /r:RemoteTime.dll TimeListener.cs
csc /r:c:\src\RemoteTime.dll c:\src\TimeListener.cs