Re: NT Service Problem




"Susanna" <Susanna@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:5FA89596-956E-40C1-AF75-E2A5EAE5B593@xxxxxxxxxxxxxxxx
You've got it right , the problem is with not terminating the threads.
I'll try doing a terminatethread on stop.

Also I dont know how to attach a debugger to NT Service, so used the log
files instead.

To debug I just clicked on the NT Service exe in the task manager and
clicked on debug option and it says "Access is denied". Is that how a
debugger is attached?

In Visual Studio 2005 you would use the Tools\Attach to Process menu item
and select your service executable from the process list. Make sure that
you check the box that allows you to view processes from all users. In
addition, unless your service is running under your account credentials, you
must be using an administrative account or one with the appropriate
privileges in order to debug the process.

Lastly, I looked at the code snippet that you have posted as well as your
general comments here and would like to suggest the following:

1. Rethink and rewrite your service. Based upon your statements here, your
architecture sounds flawed.
2. Use the ATL service classes to create your base service template code.
This allows you to concentrate on the functionality of your service rather
than the boilerplate code.
3. Make sure that you concentrate on resource allocation, usage and cleanup.
A service is intended to run *forever*. A resource leak will slowly starve
your system.
4. Do *not* use the TerminateThread.
5. Pick up a good book or two and *read* them. I suggest the following:

1. Developing Server Side Applications for Windows 2000
http://www.amazon.com/o/ASIN/0735607532
2. Programming Applications for Microsoft Windows
http://www.amazon.com/Programming-Applications-Microsoft-Windows-General/dp/1572319968/sr=1-8/qid=1158073793/ref=sr_1_8/102-1222395-3979355?ie=UTF8&s=books

I don't mean to make it sound as if I am denigrating your skill as a
developer, but just be aware that service application development requires
much greater knowledge and care than does "normal" application development
for reasons described in the Richter books.

-Pete


.



Relevant Pages

  • Re: How to connect to children process
    ... Main problem is amount of manual operations required per debug cycle. ... connection to DLL with debugger takes sensible amount of time and manual ... Is the main problem that the debugger keeps symbols file loaded ... AFAIK that's how VS2003 debugger works, but WinDbg should usually ...
    (microsoft.public.vsnet.debugging)
  • Re: Need Help Debugging
    ... you should use straight and plain ADPlus.VBS from the debugger package. ... debug info loaded, etc... ... does that avoid using the stack ?!? ... which is our custom CRITICAL_SECTION class. ...
    (microsoft.public.win32.programmer.kernel)
  • gnome-settings-daemon crashed twice
    ... To debug your program, run it with the --sync command line ... backtrace from your debugger if you break on the gdk_x_errorfunction.) ...
    (GNOME)
  • Re: DesignBAIS/Dave Bryant
    ... As Tony says you can also "debug" your code in the DB app (browser ... form of tcl access and are able to enter the native debugger anyway. ... i could enter the debugger on their public internet site they would ... Not all Visage applications are deployed to Public internet sites. ...
    (comp.databases.pick)
  • Re: SUnit disappointment
    ... I always press the 'Debug' button in the SUnitBrowser when I'm ... For example when examining a failure in the debugger rather ... I'll often be able to fix the failure in my second ... > Equals verify: object printString with: 'test' ...
    (comp.lang.smalltalk.dolphin)