I'd like to create and manage a Windows Service application without "help" from Visual Studio's designer.
Since this is .NET, and judging by MSDN and what the designer does, this means inheriting from Installer
, and constructing and dealing with ServiceProcessInstaller
and ServiceInstaller
to be able to manage the install-time execution of the serivce.
Runtime, this means creating a ServiceBase
subclass and starting it from Main
using ServiceBase.Run
(and overriding various ServiceBase
event handling methods).
However, when I do this, Visual studio insists on treating the Installer
and ServiceBase
subclasses as designer-edited files. This doesn't exactly help readability, not to mention the fact that it generally can't deal with handwritten code at all. I'd like to avoid the designer to keep things manageable (to avoid nebulous who-knows-what-runs-when, particularly for code that's tricky to test and debug such as windows services that after all must be installed to be run at all), and also to be able to specify the service name at run-time, rather than at compile time - the designer doesn't support that.
How can I create a windows service application without all the gunk?
VS does add some extra stuff but I wouldn't really worry about it. Here's a tutorial for creating a simple service manually in VS2005, it should work just fine for new versions, too.
http://www.codeproject.com/KB/system/WindowsService.aspx