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 / June 2007

Tip: Looking for answers? Try searching our database.

Debugging a Windows Service

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Carlos Sosa Albert - 05 Jun 2007 21:53 GMT
Hi guys,

I'm trying to do just this, debug a Windows Service. I tried some ways I
found around the net but I wasn't able to get it to work.

This I found at http://www.codeproject.com/dotnet/DebugWinServices.asp and
seems like a nice approach, but when it talks about "<Your Service's Primary
Method Here>" I don't know what to do... =/

Any help, will gonna be VERY welcome.

           //#if (!DEBUG)
           //    System.ServiceProcess.ServiceBase[] ServicesToRun;
           //    ServicesToRun = new ServiceBase[] { new Service1() };
           //    ServiceBase.Run(ServicesToRun);
           //#else
           //    // Debug code: this allows the process to run as a
non-service.
           //    // It will kick off the service start point, but never
kill it.
           //    // Shut down the debugger to exit
           //    Service1 service = new Service1();
           //    service.<Your Service's Primary Method Here>();
           //    // Put a breakpoint on the following line to always catch
           //    // your service when it has finished its work
           //
System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
           //#endif

Thanks,

Charly.
Bryan Phillips - 06 Jun 2007 02:46 GMT
I use this for everything:

#if DEBUG
    if (!System.Diagnostics.Debugger.IsAttached){
        System.Diagnostics.Debugger.Launch();
    }

    System.Diagnostics.Debugger.Break();
#endif

--
Bryan Phillips
MCT, MCSD, MCDBA, MCSE
Blog:  http://bphillips76.spaces.live.com
Web Site:  http://www.composablesystems.net

> Hi guys,
>
[quoted text clipped - 28 lines]
>
> Charly.
Carlos Sosa Albert - 06 Jun 2007 14:10 GMT
Thanks a lot Bryan, it worked like a charm.

Do you by any chance have some link/idea of documentation about Windows
services? Is the first one I'm working on and I feel a little bit lost... =P

>I use this for everything:
>
[quoted text clipped - 47 lines]
>>
>> Charly.

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.