Windows Forms to Windows Service Process to Process Communication Using WCF

I've been working on a side project for an application that will run on Windows Vista.  It involves a Windows Service that does P2P and WCF Endpoint code to do some communication.  I wanted to setup a WinForms app that could talk to it.  I could just set up another http endpoint, but that would be slower and open up my security surface area.  Instead I wanted my application to talk to the Windows Service in memory.  The way to do this is through named pipes in WCF.  It was fairly easy to figure out how to do, but currently WCF is a bit picky on the details so it took a while to get it going.  I thought I'd share how to setup this up with some sample code.  Note: I didn't use WPF for the UI because I don't know it well enough yet and know Windowns Forms pretty well.  I imagine a WPF app would connect about the same.

Setting up the WCF Service and Contract

Setting up the Named Pipe

Setting up the Metadata Service

Connecting to the Service

 Enjoy!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s