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,
No, you should not have 2 services with the same name. It is mentioned in the Service Configuration Guide that service names should be unique.
Microsoft Windows services, formerly known as NT services, enable you to create long-running executable applications that run in their own Windows sessions. These services can be automatically started when the computer boots, can be paused and restarted, and do not show any user interface.
Choose "Visual C#" >> "Windows" project type and select "Windows Service" from the right hand side and name the project "TestWindowsService" as shown in the following screenshot. After you click "OK", the project will be created and you will see the design view of the service as shown in the following screen.
Windows Services broadly fall into three categories depending on the actions and applications they control: Local Services, Network Services and System. Third party applications such as antivirus software may also install their own services.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With