Controlling a Windows Service (with a Form).

  • Thread starter Thread starter Phil Jones
  • Start date Start date
P

Phil Jones

I'm looking at wrapping an app I have up within a Window's Service.

I haven't done this before, and I've been readng through the .NET Ref
overview topic on the subject. Basically my question is this. There's a
lot of discussion about how you can't use any UI with a service (which makes
sense), but I'm thinking about a management UI that configures the service
app's settings.

There is some discussion about the ServiceController component - and I'm
wondering: could I write a win-forms app that somehow uses this component to
achieve what I'm talking about. Ideally I'd like to be able to launch it by
double clicking the service (or something like that).

Am I thinking in the right area - or just totally off base here? A few
words of wisdon at this point might save me a lot of mucking around!

Thanks everyone.
===
Phil
 
You will need some interface (in a broad sense) to communicate to the
service. For example, the service can create a controller object available
through .NET Remoting. Another approach I've heard about is exposing service
functionality through COM, but this incurred some hassle with C++ and might
incur even more with .NET - never tried this, so not sure about the
implementation details.
 
You are on the right track. I have a service and a WinForms app that is an
interface to the service configuration, etc. The service updates a table. The
WinForms app can stop, start, initiate a command, and run reports on the
table. The service is also available from the usual "Services" section if
"Administrative Tools, etc"

Remember, the service should ideally have no visual component of it's own.
This allows it to run while no user is logged onto the machine. Also, perform
complete error checking. I recommend logging errors someplace.

There is sample code available on MSDN somewhere. That is how I got started
 
Back
Top