Interprocess Communication via Self Hosted WCF

Lately I was asked if there is a way to allow 2 apps to communicate even if they are belonging to 2 different exe’s . Fortunately for me I have the source code of both 2 apps. The main reason why instead of merging the projects, we went to IPC or interprocess communication is because, I belong to a team that maintains the other windows forms app and the other project or exe belongs to another team that has their own deliverables. And another thing is, we want to deploy the IPC functionality the soonest. It means it is badly needed.

The way to do it is have a listener in the second app and let the first app talk to the second app with the same url.

Oh, first lets create something (object) that can be shared between the 2 apps. When you communicate, you transfer knowledge, words, etc. In our case lets transfer some data to the other app.

The Data

public class UserInformation
public string Name { get; set; }

public DateTime BirthDate { get; set; }

public string Address { get; set; }

The Service Contract

This will be self hosting service which will be hosted in the listener app.

[ServiceContract(Namespace = “”)]
public interface IUserServiceContract
int UpdateUserInformation(UserInformation userInformation);


The Service Implementation

[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
public class UserService : IUserServiceContract
public int UpdateUserInformation(UserInformation userInformation)
return 1;

Starting the listener

This code block will be in the listener app. What it does is we instantiated a wcf service inside our windows app via named pipe.

Dim address As String = String.Concat(“net.pipe://localhost/user/userservice”, Environment.UserName)
Dim _userService As UserService = New UserService()
Dim serviceHost As New ServiceHost(_userService e)
Dim binding As New NetNamedPipeBinding(NetNamedPipeSecurityMode.None)
serviceHost.AddServiceEndpoint(GetType(IUserServiceContract), binding, address)

Calling the listener

Here we called the listener via the same url that was instantiated in the listener app. Then we created a UserInformation object and passed it like we do in a normal wcf service.

Dim address As String = String.Concat(“net.pipe://localhost/user/userservice”, Environment.UserName)
Dim binding As New NetNamedPipeBinding(NetNamedPipeSecurityMode.None)
Dim ep As New EndpointAddress(address)
Dim channel As IUserServiceContract = ChannelFactory(Of IUserServiceContract).CreateChannel(binding, ep)

Dim _userInformation as new UserInformation()
_userInformation.Name = “Franco Robles”
_userInformation.BirthDate = DateTime.Parse(“1985-10-08”)
_userInformation.Address = “Makati, Philippines”


And thats pretty much about it. There are many types of IPC (Inter Process Communication), WCF via named pipe just suits my needs. Maybe you encounter the same scenario sooner or later and hopefully this post will be a starting point for you.

Happy Coding!!!







The Project Tracker

It’s been a long time since I havent created a blog about silverlight. Ill make this short since I have lots of things to do, not just silverlight. Today, I am going to show my latest addition to my projects “The Project Tracker”. This will show that silverlight is not just for media.

First Screen
The home screen. This window will list all the current user’s projects with Active Directory authentication.

Second Screen
The project creation screen. This window is where you save your current projects for tracking.

Third Screen
The project attachment screen. This window is where you attach supporting documents for your project.

Fourth Screen
The query screen. This window is where you will find the projects by you and your teammate and can be filtered via there status.

Fifth Screen
The history window. This window is where you will keep track of who commented or did something to your posted project.

Sixth Screen
The notification module. The highlighted object will slide up and stays for 5 seconds which acts like other notifications in the taskbar.

Now who said that silverlight is just for animations and other things. Lets make it simple and straight. If you want a rich interactive web application for your audience use Silverlight.

Testing WCF Services with WCFTestClient

This is for those who dont know this Add-in tool yet which is very usefull when it comes to developing WCF services. I’ve been searching for this Add-In since, luckily I had a Team Lead which is not that selfish in terms of knowledge sharing. So I will do the same for those who has problems debugging their wcf service.

Okey here are the steps.

1.) Locate the add-in which resides on your installation path under \Microsoft Visual Studio 9.0\Common\IDE\WcfTestClient.exe

IE: C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\WcfTestClient.exe

2.) Add WCF TestClient to your External tools under Tools > External Tools menu of VS 2008. Under the Command field, copy and paste that path of the WCFTestClient.exe. And you name the tool in the Title field like the image you see below.

Debugging Example

1.) Build your project containing the wcf service.
2.) Launch the WCTTestClient which will appear under the Tools menu of Visual Studio 2008 after adding in the external tools.

3.) Right-click “My Service Projects” and select “Add Service”

4.) Once the service is successfully added. Your service operations will be listed in the left pane. To test these service operations, just double – click the operation and press invoke.

Any breakpoint(s) in the service method which is invoked will cause a break point after pressing invoke.

Finally, our problem of testing a wcf service has been made easy with Visual Studio 2008’s WCF Test Client.