views:

237

answers:

3

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

+3  A: 

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).

Marc Gravell
+3  A: 

Just expose it using WCF and call it from your other app. They are in different processes so you have to use IPC

Hans Malherbe
+2  A: 

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.

Preet Sangha