Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / November 2006

Tip: Looking for answers? Try searching our database.

Windows service debugging

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jarod - 14 Nov 2006 09:44 GMT
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
Kevin Spencer - 14 Nov 2006 12:32 GMT
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.

Signature

HTH,

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

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

> Hi!
>
[quoted text clipped - 12 lines]
>
> Jarod
Ciaran O''Donnell - 14 Nov 2006 13:19 GMT
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

> Hi!
>
[quoted text clipped - 8 lines]
>
> Jarod
Dale - 15 Nov 2006 01:25 GMT
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
Signature

Dale Preston
MCAD C#
MCSE, MCDBA

> Hi!
>
[quoted text clipped - 8 lines]
>
> Jarod

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.