RE: Could not Debug
- From: jetan@xxxxxxxxxxxxxxxxxxxx ("Jeffrey Tan[MSFT]")
- Date: Fri, 14 Jul 2006 06:08:59 GMT
Hi Siva,
Thanks for your post!
Yes, Windows Service is a special type of application in Windows world, it
is different from GUI or console Applications. Below is some difference
details:
1. Windows Service is communicating with SCM, and it must obey the rule of
SCM. For example, while the service is starting, SCM allows the service to
response in 30 seconds, if the service does not response in this period,
SCM will kill your service. So was the stop or any other actions.
2. Windows Service normally runs in another Logon Session, so it has its
own Windows Station/Desktop, which is different from our interactive
Windows Station/Desktop. So its output will be invisible to us.(For
example, if you use Process.Start to lauch a notepad, you will find you can
not see it)
Because of these features, Windows Services become the hardest type of
application to debug except Windows Driver.
Based on the above background information, normally, the easiest way to
debug windows service application is first run it normally as a console
application, after performing the normal code stepping and debugging, you
may release and install it. This is easy to be done, the article below
shows this trick:
"Debugging Windows Services under Visual Studio .NET"
http://www.codeproject.com/dotnet/DebugWinServices.asp
However, this trick can only to test half of your code, because your code
may run well under console application, but it fails while running as a
service.(Normally, because of #1 and #2 features). At runtime, after your
service is started, you may use VS.net to attach to the service running
process and perform the debugging. Genernal information can be found in the
article below:
"How to: Debug Windows Service Applications"
http://msdn2.microsoft.com/en-us/library/7a50syb3.aspx
Finally, if you want to log information from Windows Service, because of
#2, we can not simply output it with Console.WriteLine. The easiest way is
using EventLog, please refer to:
"How to: Log Information About Services"
http://msdn2.microsoft.com/en-us/library/f6567h1s.aspx
Above is the general debugging guideline, if you still have some specific
difficulties, please feel free to tell me. Thanks!
Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
.
- Prev by Date: Re: Debugging with dumps
- Next by Date: Re: Function names for managed callstack under SOS debugging of .NET 2.0 app
- Previous by thread: No Intellisense in Command window
- Next by thread: Re: Weird Compiler Error
- Index(es):
Relevant Pages
|