Link to home
Start Free TrialLog in
Avatar of lynq
lynq

asked on

WCF, C#, simple self-hosting code requested

I'm a complete beginner with WCF and am looking for some basic code sample that will achieve the following:

I have two .NET applications running on a machine. Application A can tell Application B to "Do Something" with a few parameters. There is no need for Application B to respond to Application A.

In the past, with VB6, I might have simply had Application A launch B with some command line parameters. Alternatively, I might have had Application B listen to a TCP port for some communication.

However, now I want to try WCF under .NET with C#.

Okay. My first thought was I could create a WCF service, self-host it in Application B and, when Application A sends a message (via whatever communication type, but probably net.tcp), simply raise an event in Application B so it knows it's been called. I can create a service. I can communicate with a service one-way or returning values. I just can't get the service to raise events in the hosting application. Is this even possible?

My second thought: Application B needs to "subscribe" to the service perhaps and receive callbacks when Application A sends the message? I think I understand the principle but I can't get my head around the source code I've found on the web.

Ideal solution from an expert: some code - or link to something similar enough - that implements a very simple service that will allow one client to send a message to it and another client to receive that message by way of an event raised within the hosting application of that second client. I've read through and tried to adjust so many chat room samples online it's not funny anymore and they all seem to rely on the server component of the chat system being the top-level application; I don't want that. Also, a code-only solution rather than one that relies on config files would be preferred; I'll tackle the config afterwards but I need to try to get to grips with the programming model first.

Thankyou in advance to anyone who replies.
ASKER CERTIFIED SOLUTION
Avatar of vbturbo
vbturbo
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lynq
lynq

ASKER

That first link to the EventDrivenComFoundation pointed me in the right direction for what I was after. I can't believe how much I've trawled codeproject without finding that solution so thanks for providing some extra eyes.