7

I have 2 windows services that I created using C#.

I would like one of the services to call a function in the second windows service.

How should I do it?

EDIT:

The issue is That I have to application that running ( I don't need them to be Rather service Process is good too) but I need this 2 application to communicate, this 2 application are on the same server,

MoShe
  • 6,197
  • 17
  • 51
  • 77

3 Answers3

5

Sure. There are a bunch of IPC mechanisms you could use. Remoting, TCP/HTTP Listeners, etc.

Does either service provide functionality that might be useful outside of the other service?

See this thread for more ideas: IPC Mechanisms in C# - Usage and Best Practices

EDIT: As Davide Piras pointed out, if WCF is available for you to use, then consider using it. It will simplify life. The WCF configuration files are sometimes a pain to wield, but there's a nice tool for that too: http://msdn.microsoft.com/en-us/library/ms732009.aspx

Community
  • 1
  • 1
jglouie
  • 12,523
  • 6
  • 48
  • 65
5

Are the services on the same box? Do you have .NET 4? Highly recommend using the fastest mode possible, memory-mapped files.

If they're on the same box, but you don't have .NET 4, or are in a homogenous Microsoft Windows network, named pipes could work. More to the point, I'd use WCF over a named pipe.

Community
  • 1
  • 1
Jesse C. Slicer
  • 19,901
  • 3
  • 68
  • 87
4

I found all the other answers correct but a little too much complicated (WCF is a big deal) and not scalable (memory and named pipes will only work on the same sever). I suggest you DotNetMQ messaging system. It's easy to use and deploy and let's you communicate even between processes running on different servers.

Kurubaran
  • 8,696
  • 5
  • 43
  • 65
gigi
  • 796
  • 9
  • 21