Is this really true? I have about a dozen icons in my Tray, about half of
them represent running services (e.g. PCAnywhere, SQL Server, Bluetooth,
etc.).
I'll reiterate: I don't really know much about writing services.
I do
_use_ them all the time though.
That said, my understanding is that the "dozen icons in your Tray" are the
UI side of the services, not put there directly by the service process.
Services can (and usually do) start without there being a logged in user
or any GUI available. So services by themselves wouldn't be able to
present a user interface, not being able to know in advance if there is
even a way to do so.
I suspect that for each of those icons in your task tray, there is a
user-side process somewhere that talks to the service for the purpose of
controlling it. You should be able to look in the Task Manager process
list (or use SysInternals Process Explorer, which provides more detailed
information) and identify processes that are services vs. processes that
are running in your logged in user's space. It is likely that you could
terminate the user-side process, without affecting the service, but
resulting in the loss of the task tray icon (you'll have to mouse over it
first to see it disappear, as the icons aren't removed until Windows tries
and fails to actually contact the process that put it there).
Writing a service is a bit of a black art from what I can see;
Oh, I don't know about that.
Well, actually...I _literally_ don't know about that. Still, I don't see
what's so difficult about it. Perhaps I'm simply speaking from
inexperience, but I don't see why a service should be any different from
any other process, except that there's no user interface. I mean, I
realize there may be particular things a service is required to implement,
things that actually make it a service. But otherwise? I don't see what
would make it so arcane.
Since a
service won't run in the IDE it's difficult to step through the code
during
the development in order to test it.
I didn't realize that a service won't run in the IDE. Can you elaborate
on that?
In any case, I would guess that remote debugging might be useful in that
scenario. That's what I use when I'm trying to debug something that for
whatever reason doesn't work when the process is started from within the
IDE (as an example, debugging drawing code is pretty challenging without
remote debugging, since every time you step in the debugger, focus
switches from the application back to the debugger, forcing new redraw
events and invalidating existing drawn graphics).
Also, I have seen people here mention that they do essentially what you've
done, with respect to debugging. A common technique seems to be making
the service a console application for the purposes of debugging, then
removing the small console wrapper required when actually deploying the
service.
[...]
Are there any whitepapers which describe logistics and best-practices for
service development using Visual Studio 2005? I am managing, but if there
are specific recommendations and approaches which work better than
others,
I'd like to read up on them.
Hopefully someone with more experience with writing services can answer
that question. I think it's likely there are documents on MSDN for it,
but don't know off-hand where they are.
Pete