Click here to Skip to main content
14,920,539 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I create windows services & Event log in my project.But not run shortly below code:
Dim ServicesToRun() As System.ServiceProcess.ServiceBase
ServicesToRun = New System.ServiceProcess.ServiceBase() {New NotificationService()}

NotificationService is a constructor.
And msg is shown 'Cannot start service from command line or debugger. A Windows service mest first be install(using installutil.exe) and then start with the ServerExplorer, Windows Services Administrative tool or the NET START command'
Updated 21-Nov-11 1:25am

1 solution

You need to do exactly what the message tells you. You are trying to run interactively the application designed to run hosted by the system service host only. You really need to install it and run using Services applet; use "Services.msc".

If you want to install with InstallUtil.exe: it works in conjunction with classes in the System.Configuration.Install namespace which you will need to implement.

You will need to provide implementation of ServiceProcessInstaller and ServiceInstaller, see:[^],[^].

These are just links to the API you will need to get into it. You will need to learn these techniques thoroughly as they are not very simple and somewhat counter-intuitive. MSDN is your friend.

Abhinav S 21-Nov-11 13:43pm
5. Useful to the OP.
Sergey Alexandrovich Kryukov 21-Nov-11 13:45pm
Wow! You've been very fast.
Thank you, Abhinav.
Abhinav S 22-Nov-11 0:50am
You are welcome. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900