Jeroen,
Is the communication one way or two way?
You can use System.ServiceP rocess.ServiceC ontroller in the config.exe to
monitor if the service is running, as well as start, stop & pause the
service. You can use ServiceBase.OnC ustomCommand &
ServiceControll er.ExecuteComma nd 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 ServiceControll er 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.Manageme nt 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.Diagnost ics.EventLog & System.Diagnost ics.Performance Counter.
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.Channe ls.Ipc.IpcChann el for .NET remoting that is
local machine only, plus System.Net.Secu rity.NegotiateS tream to secure
Remoting across machines.
FWIW: When restarting a service I use a routine similar to:
Public Shared Sub RestartService( ByVal controller As ServiceControll er)
controller.Stop ()
controller.Wait ForStatus(Servi ceControllerSta tus.Stopped)
controller.Star t()
End Sub
--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley -
http://www.tsbradley.net
"Rotzooi" <ro*****@bukowo nen.nl> wrote in message
news:OB******** ******@TK2MSFTN GP12.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******** *******@TK2MSFT NGP15.phx.gbl.. .
| >I was going by the email address.
| >
| > "Rotzooi" <ro*****@bukowo nen.nl> wrote in message
| > news:OJ******** ******@TK2MSFTN GP14.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******** ******@tk2msftn gp13.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
| > |
| > |
| >
| >
|
|