Using windows services [written in C#] using C#
-
10-07-2019 - |
Question
I wrote a windows service in C# that does some functionality (a public method) after reading a file at regular intervals. Is it possible for me to use this functionality from another C# application ? If possible, please give a solution based on .net 2.0 as well as .net 3.0
Thanks
Solution
The cleanest option would be to write that functionality in a separate assembly (dll) that you use from both the service and the second .NET application.
You can reference the service assembly (even if it is an exe, in VS2008 at least) - but it seems a little overkill.
If you want to execute the method in the context of the running service, then you'll need some IPC (perhaps WCF or sockets).
OTHER TIPS
Just expose it using WCF and call it from your other app. They are in different processes so you have to use IPC
Depends hwo you want to reuse.
If you want to access the running window service then expose then functionality via WCF. Of you want to just use the code then place it in a assembly and reference from another project/program.
I'd say the .net 2.0 and 3.0 would be the same from the latter but since .net 2.0 fmk does not have WCF I'd suggest a windows remoting endpoint for the earlier if you're using .net 2.0 only or WCF as I stated.