Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / June 2005

Tip: Looking for answers? Try searching our database.

"self-installing" service

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lucvdv - 06 Jun 2005 13:33 GMT
I used to create services in a 'self-installing' way: a single executable
that serves both as the service executable and as configuration/install
program.

Depending on a command line option they start either the service itself
("-service" present) or a configuration/install GUI (switch not present).

Is there a way to use this approach in a ServiceBase-derived class with the
CLR's built-in classes, without going through raw APIs?

Can it be done at all?  Is the Main() function in a class derived from
ServiceBase called from the "real" main() function (the exe's entry point)
or from ServiceMain, the service entry point that's passed to the SCM by
main()?
Sahil Malik [MVP] - 06 Jun 2005 18:44 GMT
You can get very easily get real close to what you are trying to acheive.
You can pass command line parameters to a service, and have it start as a
regular windows app - makes debugging a lot simpler. I blogged about that at
one point right here -
http://www.codebetter.com/blogs/sahil.malik/archive/2004/12/06/35295.aspx

And then you can also install it as a service using MSI or command line
tools (msi preferred). Once it is installed, then you can use it as either
command line (it is an exe afterall) or as a service.

If you really really wanted the exe to be smart enough to register itself as
a service - when run without parameters, you can use Win32 Api to install a
service - the overall approach remains the same as described in my blog post
at http://www.codebetter.com/blogs/sahil.malik/archive/2004/12/06/35295.aspx

- Sahil Malik [MVP]
Upcoming ADO.NET 2.0 book - http://tinyurl.com/9bync
----------------------------------------------------------------------------
---------------

> I used to create services in a 'self-installing' way: a single executable
> that serves both as the service executable and as configuration/install
[quoted text clipped - 10 lines]
> or from ServiceMain, the service entry point that's passed to the SCM by
> main()?
Lucvdv - 07 Jun 2005 07:44 GMT
> You can get very easily get real close to what you are trying to acheive.
> You can pass command line parameters to a service, and have it start as a
> regular windows app - makes debugging a lot simpler. I blogged about that at
> one point right here -
> http://www.codebetter.com/blogs/sahil.malik/archive/2004/12/06/35295.aspx

Thanks, I'll have a look at it.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.