You cannot just hit Run and debug your Windows Service. That would be really cool, but it is not that hard to get it running.
Build and Install service on your pc:
Choose Build in the Menubar above and choose Build NewService.
This will build your executable in the bin\release folder of your project. If you try to run the program by itself, it will not run and give you an error. Instead you have to load the service into your computer by using InstallUtil.exe.
You can run InstallUtil.exe from the VisualStudio Command Prompt.
Installing:
InstallUtil “PATH_TO_YOUR_EXE.exe”
Uninstalling:
InstallUtil “PATH_TO_YOUR_EXE.exe” /U
When you run in the command window, you will see alot of text, and at the bottom it should read:
The Commit phase completed successfully.
The transacted install has completed.
Now we have to start the service in Service Manager. – Right click on My Computer on the Desktop, and choose Manage.
Choose Services and Applications, Services, and New Service:
Right click and Choose Start.
Then Go to EventViewer, Application and you should see a log for service starting, and after 10 seconds you should see your ‘Service Running” log entry
Now you have a running Service. Don’t forget to stop it. You dont want to fill your Event log up! We set the service to Automatic in Part 2, so you may want to uninstall using InstallUtil.exe to remove from your system.
Next we will build a Setup package so you can install easily on computers that are not running Visual Studio.
Services Part 4:> Build Setup Package for your Windows Service
Programmers – Use your talents to make some money online. Click Here to Read More
Awesome article! Well done!
http://www.dotheweb.net/2009/10/building-and-installing-windows-service-visual-studio-2008/
Get error 5 access is denied Could not start the NewService service on local computer
Ah sorry I chose the wrong type localservice not localsystem had to uninstall and then REBOOT
Thank you for article.
Love how simple and click-by-click this was done. Well written & works great.
Thanks kindly.
Hi,
I am facing an unknown issue while I am trying to debug windows service.
I have created service, built it in debug mode and successfully installed it using installer. My service is reflecting in services.msc but when i try to attach a debugger to it nothing happens. Break point does not get any hit.No error nothing.
I also checked the logs. Service is started successfully and ended successfully.
Does any one has some idea why this is happening?
thanks for this helpful information.