Bob Rundle
7/8/2004 8:13:00 PM
Sunny,
Thanks...I know all about the Debug class.
Nothing replaces the debugger however and the ability to single step and
examine variables. Programmers complain that windows services are hard to
debug, but with a few #if/#endif you suddenly have an orginary windows app
that is easy to deal with. I don''t understand why people don''t approach
services this way, at least in development.
Your idea to create a separate console app for debug is a good one, except
that it would mean creating yet another VS.NET solution and I have more than
enough of these already.
So I will stick to my #if/#endif code. It works but it is ugggglay!
Regards,
Bob Rundle
"Sunny" <sunny@newsgroups.nospam> wrote in message
news:e2g1SYSZEHA.3844@TK2MSFTNGP10.phx.gbl...
> What I would do is to put all my functionality in a separate class, and
> to use OnStart just create an object from that class and pass the
> execution into it.
>
> Then, my class will implement an event DebugMessage.
>
> That way, I can easily create a console app, in which Main method I''ll
> create the object (like in the service), and hook an event handler in
> which I''ll record the output.
>
> And whenever you need to write something, you just invoke the event.
>
> So, if the event is captured, there will be output, otherwise, not.
>
> Or, you can take a look at this article in MSDN:
> ms-
> help://MS.VSCC.2003/MS.MSDNQTR.2004JAN.1033/vbcon/html/vbtskaddingtraces
> tatementstoapplicationcode.htm
>
> And take a look at Debug class. It''s methods are invoked only if the
> this is a debug compilation, so in release there will be no output.
>
> Sunny
>
>
> In article <uwaa$MSZEHA.3132@TK2MSFTNGP10.phx.gbl>, rundle@rundle.com
> says...
> > There doesn''t seem to be a newsgroup for .NET windows services, so I''ll
ask
> > this question here...
> >
> > I want to create a debug version of my windows service so which is not
> > derived from System.ServiceProcess.ServiceBase. I want to do this so I
can
> > easily debug the process.
> >
> > At the present moment I have a lot of #if DEBUG/#endif sections in the
main
> > service process to accomplish this. My question is: Is there a more
> > elegent way to do this?
> >
> > Bob Rundle
> >
> >
> >