Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Is it possible to call windows service from another windows service in C#? I have created two windows services WindowsService1 and WindowsService2. I want to call WindowsService2 in WindowsService1, means call one windows service to another windows service. Please give me a solution.
Posted
Updated 1-Sep-11 2:07am
v2

Yes. See the ServiceController class[^] - it contains an example.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 7-Mar-11 2:42am    
The problem is that there is not such thing as "call a service".
Probably you answer it the only interpretation of this which makes certain sense, my 5.
Apparently, the services can interact using various IPC such as sockets, WCF, remoting, etc.
--SA
You don't "call" a service. You can control it (start, stop, pause, resume, and custom commands), but you can't call it.

As Griff has already stated, the ServiceController object is what you want to use.
 
Share this answer
 
If you need to call the functionality within another service you have to setup a messaging system for that service, usually TCP connections.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900