Click here to Skip to main content
15,890,336 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a windows service called WindwosService1 which is already running in the background. I have to create another windows service which will call the method of WindwosService1 while its running. how to achieve this. I am new to c# and even a slightest help will be much appreciated! thank you!

Edit: WindowsService1 is already created service which i cannot change. i just have to install it and run it. this windows service has a desired method which i want to call using another windows service (WindowsService2) which i will be creating. is it possible to expose method of already created service(WindowsService1 which i dont have rights to modify) using WCF?

What I have tried:

I have tried adding a reference to the service and calling the method by that reference.
Posted
Updated 16-Jan-17 0:09am
v2

1 solution

Assumption: Service 1 and Service 2 are two different processes running as windows service
Answer: You will not be able to call this method by reference because two different services will have its own memory allocation and execution. If you are not interested in sharing service memory and process & you have logic in a separate Assembly you can add reference and start using it. If you need to execute logic inside same process and memory of other service, best way to achieve this would be to expose an rest-based API or socket TCP based connection. You can go with WCF or Web API base self hosting. Also look for singleton, adapter and Creational design pattern.

We implemented similar logic using WCF self hosting with Event-driven implementation.

Thanks,
Ashwin
 
Share this answer
 
Comments
Afzaal Ahmad Zeeshan 16-Jan-17 7:35am    
5ed.

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