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 / Languages / C# / August 2007

Tip: Looking for answers? Try searching our database.

Can't debug windows service.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Manohar - 23 Aug 2007 19:08 GMT
I have created a windows service which works quite good.  I am
executing a stored procedure and check the status of few data.  After
installing, it works good.  But, when I tried to debug the windows
service by attaching the process from VS 2005, all the breakpoints
which I set turned to the infamouse message:

"The breakpoint will not currently be hit.  No symbols have been
loaded for this document."

1. I have built the service in debug mode.
2. pdb file and the exe file have the same timestamp.

Can somebody help me out in this?

Thanks
Marc Gravell - 23 Aug 2007 23:53 GMT
I find the easiest way to debug a service is to develop it as a
console exe with an optional command-line switch (such as -c) which
(if present) makes the entry-point [aka Main()] run the actual code,
rather than the usual ServiceBase.Run(...)

This way, you can debug directly in VS2005 by specifying the debug
command-line and pressing "play". For serious development this is a
lot quicker than the build cycle for a one-line change in a genuine
service (NET STOP, build, NET START, attach debugger... yeuch)

Note that this helps with general functional debugging, but there are
some subtle nuances related to security etc that are different when
running as a bona-fide service. Once it works in console mode, you
also need to verify that it works correctly as a service; you
shouldn't have too much trouble.

Marc
rmacias - 24 Aug 2007 20:58 GMT
Make sure you place the debug files in the same location where your service
is registered at.

Also, what i do to make debugging services somewhat simplier is on the
OnStart() event handler, I place a

Debugger.Launch();

statement.  What this does is that it generates the "An uhandled exception
caught, do you want to Debug?" window.  From that Window I choose the
instance of Visual Studio that has my opened solution (assuming your VS
Solution is opened).  Then my breakpoint hits, even breakpoints in the
OnStart() event handler.

> I have created a windows service which works quite good.  I am
> executing a stored procedure and check the status of few data.  After
[quoted text clipped - 11 lines]
>
> Thanks

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.