473,385 Members | 1,536 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

how to debug windows service

hi all,
how to debug windows service in c#.net

thanks in advance
Regards,
Tulasi


Dec 29 '05 #1
5 13302
There are 2 main ways to do this. I prefer to build business classes that do
the actual work of the service. I can then test them in a Windows
executable, and once debugged, plug them into a service. The other way is a
bit more difficult.

You create your Service. You install it and start it. In Visual Studio.Net,
you attach to the process (Debug|Processes... menu), and then you can debug
as usual.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

"TulasiKumar" <tu*********@nannacomputers.com> wrote in message
news:e3***************@TK2MSFTNGP15.phx.gbl...
hi all,
how to debug windows service in c#.net

thanks in advance
Regards,
Tulasi

Dec 29 '05 #2
Hi,
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
You create your Service. You install it and start it. In Visual
Studio.Net, you attach to the process (Debug|Processes... menu), and then
you can debug as usual.


Note that in this way you cannot debug the onStart event.

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Dec 29 '05 #3
True. Another reason why I use business classes instead!

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:u%*****************@tk2msftngp13.phx.gbl...
Hi,
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
You create your Service. You install it and start it. In Visual
Studio.Net, you attach to the process (Debug|Processes... menu), and then
you can debug as usual.


Note that in this way you cannot debug the onStart event.

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

Dec 29 '05 #4
Try something like this:

#if ( ! DEBUG )
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[] {new YourService()};
ServiceBase.Run(ServicesToRun);
Run();
#else
// debug code: allows the process to run as a non-service
// will kick off the service start point, but never kill it
// shut down the debugger to exit
YourService service = new YourService();
service.OnStart(null);
Thread.Sleep(Timeout.Infinite);
#endif

-- Peter
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"TulasiKumar" wrote:
hi all,
how to debug windows service in c#.net

thanks in advance
Regards,
Tulasi


Dec 29 '05 #5
Hi,

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:uR**************@TK2MSFTNGP14.phx.gbl...
True. Another reason why I use business classes instead!


Yes, but beware, a windows service's environment is very different than a
win. based app. , the permissions changes , like you cannot access a network
shared, or the mapped drivers are not presents.

Also a difference is that a service needs to be installed, it cannot be run
as simple as pressing F5 , if you change the code you have to stop the
service, recompile it, copy the executable to the installed folder and
restart the service.


--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Dec 29 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: INGSOC | last post by:
Using remote debugging, I can attach to a windows service and run it in debug mode in VS.Net 2003. The problem is this service uses two supporting dlls. On the remote service, the dlls have...
5
by: SiD` | last post by:
when starting a windows service writte in vb.net, a messagebox appears: cannot start service from the command line or a debugger. A windows service must first be installed using installutil.exe ...
3
by: | last post by:
Since I need to dotfuscate my exe file anyway, does it make any difference if I use Debug or Release versions. Would a Debug version be easier to decompile/study/reverse engineer than a Release...
4
by: Rob R. Ainscough | last post by:
I've created several DLL's that I use in other projects. I "Add Reference" to these other projects pointing to my DLL. Probelm is, I can't seem to be able to step into my DLL code (from these...
7
by: Sunil Varma | last post by:
Hello all, I wrote a Windows Service in VC.NET 2005 I want to debug the solution. I tried as mentioned in the following link. ...
2
by: Elioth | last post by:
Hi, How I Debug a Windows Services in VB 2005? Thanks for all help. Elioth
1
by: thomas | last post by:
Hello all, I have a C# windows application project and a web service project, all part of the same solution. My windows application references and uses web service. Everything works as expected...
11
by: ThunderMusic | last post by:
Hi, I have a windows service that only loads a CSV file and import it's data using SqlBulkCopy in a newly created Sql Server 2005 table using 25000 rows batches. If I build the service in debug...
5
by: Jeff | last post by:
..NET 2.0 I'm working on 3 projects in VS2005: - a windows application project - dll library project - windows service This works like this: The window form call some methods in the dll...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.