
Remoting Client-Side
Originally published on my old blog at cumps.be on April 3, 2005.
After everything was done on the server side of the Remoting implementation, inside the Windows Service, it was time to add the consumer side. In the case of this project, the consumer was an ASP.NET web service running on the same machine.
This required little effort. First, System.Runtime.Remoting had to be referenced, together with the assembly containing the interface used for the controller object. After this it was possible to retrieve the controller object with the following code:
private IPlayerServiceController GetPlayerServiceController() {
return (IPlayerServiceController)Activator.GetObject(
typeof(IPlayerServiceController),
String.Format("tcp://{0}:{1}/MediaServicePlayerController",
this.configData.RemotingHost,
this.configData.RemotingPort));
} /* GetPlayerServiceController */
In this solution, the web service does not need to reference the assembly containing the real controller, but only an assembly that contains the interface. The real implementation is running on the server side, as an instantiated, marshalled object.
Once the instance was returned, using it was very simple:
[WebMethod(Description="Stop playing the queue.")]
public void Stop() {
this.GetPlayerServiceController().StopPlaying();
} /* Stop */
You May Also Like

Remoting Server-Side
Controlling a Windows Service with .NET Remoting instead of ServiceController, which could only send integers and got nothing back.

Windows Services
Windows Services, how they differ from the usual Windows Forms approach for business applications, and how I built one.

eID
My feasibility study on the Belgian eID card: what the technology is, what you can do with it, and how to implement it.



