473,802 Members | 1,986 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 13342
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|Processe s... 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.

"TulasiKuma r" <tu*********@na nnacomputers.co m> wrote in message
news:e3******** *******@TK2MSFT NGP15.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***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
You create your Service. You install it and start it. In Visual
Studio.Net, you attach to the process (Debug|Processe s... 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.mach in AT dot.state.fl.us > wrote
in message news:u%******** *********@tk2ms ftngp13.phx.gbl ...
Hi,
"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
You create your Service. You install it and start it. In Visual
Studio.Net, you attach to the process (Debug|Processe s... 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(Ti meout.Infinite) ;
#endif

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


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

thanks in advance
Regards,
Tulasi


Dec 29 '05 #5
Hi,

"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:uR******** ******@TK2MSFTN GP14.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
1494
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 been registered in the GAC. They are also in the service's directory, along with their associated *.dbg symbols. Yet, any breakpoint in the dlls is not hit. The dlls are part of the project file, and breakpoints in them can be hit when I debug...
5
13423
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 and then startede with the serverexpl, windows services or the NET START command. tryed also installing with installutil: it says there is no install packs. how can I make my service work in design mode and in normal runtime mode?
3
2204
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 version, both having been dotfuscated by the standard dotfuscator of visual studio 2003 ? Tia
4
10602
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 other projects) -- I've tried adding the source code project (that was used to build the DLL) into my current solution, but I still can't seem to step into the code of my DLL. Any suggestion? I must be missing something simple?
7
3195
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. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbconintroductiontontserviceapplications.asp But, when I started the service I got a message box saying that the service is being stopped.
2
1974
by: Elioth | last post by:
Hi, How I Debug a Windows Services in VB 2005? Thanks for all help. Elioth
1
2230
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 except for the fact that I cannot debug web service. When my client windows application calls web service method the debugger does not step in, Debug.WriteLine() statements do write to the Output
11
3150
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 mode and run it, I get descent performances. If I build it in release mode, I would expect it to at least stay as fast and maybe be faster, but I actually lose performance. I lose about 10% performance.
5
2501
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 library project (.net remoting) which again calls the actual objects running in the windows service...
0
9699
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9562
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10538
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10305
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9115
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7598
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6838
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4270
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2966
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.