Jeroen,
Is the communication one way or two way?
You can use System.ServiceProcess.ServiceController in the config.exe to
monitor if the service is running, as well as start, stop & pause the
service. You can use ServiceBase.OnCustomCommand &
ServiceController.ExecuteCommand to send custom commands to the service,
unfortunately the custom commands are limited to 128 to 255. I would
recommend using an Enum to identify the custom commands.
I've used XmlDocument in the config.exe to modify the service's app.config
file to change configuration settings, then used a ServiceController to
restart the service, so it picks up the new settings.
For richer two way communication, you can use .NET remoting.
Both of the custom commands & remoting with a service are discussed in
Matthew MacDonalds book "Microsoft Visual Basic .NET Programmer's Cookbook"
from MS Press.
You can also use WMI (Windows Management
Instrumentation) via the classes in the System.Management namespace to
monitor your windows service.
Here is an MSDN article on WMI & .NET:
http://msdn.microsoft.com/vstudio/de...ml/vs04d6a.asp
WMI also has events & custom objects for control. I consider Remoting over
WMI, unless I needed/wanted the WMI integration with Enterprise Management
tools.
In addition to/instead of WMI you can also simply use Performance Counters &
Event Logs to keep track of your service doing work. See
System.Diagnostics.EventLog & System.Diagnostics.PerformanceCounter.
Of course: You could also "roll your own" communication with Sockets or
TCP/IP clients, however .NET Remoting will safe you a lot of effort.
..NET 2.0 (VS 2005) introduces
System.Runtime.Remoting.Channels.Ipc.IpcChannel for .NET remoting that is
local machine only, plus System.Net.Security.NegotiateStream to secure
Remoting across machines.
FWIW: When restarting a service I use a routine similar to:
Public Shared Sub RestartService(ByVal controller As ServiceController)
controller.Stop()
controller.WaitForStatus(ServiceControllerStatus.S topped)
controller.Start()
End Sub
--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley -
http://www.tsbradley.net
"Rotzooi" <ro*****@bukowonen.nl> wrote in message
news:OB**************@TK2MSFTNGP12.phx.gbl...
| Thanks for the extra information about do's and don't's. Very usefull
| (although the application doesn't do much accessing system resources).
|
| How do I let the service and config tool communicate in real-time with
| eachother? This is why I had to make this in one application. Any
| suggestions or good links to such examples?
|
|
| Jeroen a.k.a. Rotzooi a.k.a. Garbage
|
|
|
| "Jay B. Harlow [MVP - Outlook]" <Ja************@tsbradley.net> schreef in
| bericht news:%2***************@TK2MSFTNGP15.phx.gbl...
| >I was going by the email address.
| >
| > "Rotzooi" <ro*****@bukowonen.nl> wrote in message
| > news:OJ**************@TK2MSFTNGP14.phx.gbl...
| > |I disagree with that. I have several other programs that are single
..exe
| > ...
| > | Jeroen
| >
| >
| > I totally missed he signed it Jeroen...
| >
| >
| > --
| > Hope this helps
| > Jay [MVP - Outlook]
| > .NET Application Architect, Enthusiast, & Evangelist
| > T.S. Bradley -
http://www.tsbradley.net
| >
| >
| > "Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
| > news:OK**************@tk2msftngp13.phx.gbl...
| > | Jay,
| > |
| > | > Rotzooi,
| > |
| > | Means something as Rotten Heap in Dutch (Garbage), could not resist to
| > tell
| > | this to you.
| > |
| > | His subscription was Jeroen,
| > |
| > | :-)
| > |
| > | Cor
| > |
| > |
| >
| >
|
|