?Hi,
What I do to develop windows services is creating 3 projects.
- Desktop application (develop/testing)
- Windows service
- SystemLogic (containing the functionality)
Create a desktop application that references the SystemLogic assembly and
construct the Main class you defined in the SystemLogic.
Do the same for the windows service.
I use for the SystemLogic a Start method and a Stop method.
From the windows service the start and stop method can be linked thru the
SystemLogic start and stop.
On the Desktop application I call the start in the FormConstructor and the
Stop in the FormClosed eventhandler.
In the SystemLogic assembly you'll program what your solution should do.
The major difference between the desktop application and the service is.
The try ... catch surrounding the SystemLogic start method will write a
EventLog record and the desktop application will display a messagebox.
I only use the desktop application for debugging/testing.
Note: If the service behaves different than the desktop version, you should
check the running user rights.
Jeroen,
"phil hunt" schreef in bericht
Nothing really fancy, I just copy couple of lines from a real window service
on how it start the app. I don't have the thing in front of me now. But it
is somehting to to do with ServiceBase, or somehting like that.