Windows service debugging

G

Guest

Hi!

How to set up windows service so I'd have a windows form and I could run for
example "start" or "stop" from it. I don't want to do it by just seting up a
reference to dll in windows form project. I'd prefer windows service to work
just as normal and I'd have this additional form of control. Because normally
to catch start event I must change the code in windows service add some
system.deb... bla bla bla.
If you can share some good resources about windows services debugging it
would be very useful for me.

Jarod
 
K

Kevin Spencer

I generally build an assembly of business classes that do the work of the
service, and whose functionality is exposed via a programming API. I can
then host these business classes in a Windows Forms app for building,
testing and debugging, and then when it is ready to deploy as a service, I
build a service that hosts the business assembly.

--
HTH,

Kevin Spencer
Microsoft MVP
Ministry of Software Development
http://unclechutney.blogspot.com

Any experience you can walk away from
is a good one.
 
G

Guest

You can add a form to the project, then in the Main method you can put:

#if DEBUG
Application.Run(new debugform());
#else
Application.Run(new therealservice());
#endif

Then the form can ever make the service object and call start/stop on it or
make the same business layer calls as the service on start / stop

Ciaran O'Donnell
 
G

Guest

It appeares you have a two-part question. How to control the service from a
Windows Form and how to debug the service. I have a two-part answer.

To control the service, implement a ServiceController in your Windows Forms
application. Search MSDN for "Monitoring Windows Services" to see how. It's
really pretty easy and the instructions there are as good as any I have ever
seen on the topic.

Once you have that, you can start, stop, pause, or continu your service from
the form.

To debug the service, open your Windows Forms application and set a break
point where one of the commands is set to the service. You will be able to
step right into the service code as long as the service was compiled in Debug
mode.

HTH,

Dale
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top