Just setup in your “Debug” tab of your Visual Studio “Windows Service” project:
- Select “Start external program” and find “InstallUtil.exe” (usually under <Windows>\Microsoft.NET)
- Then as command line argument put the name of your executable
- As a working directory, select the output folder of your project
It should look like this:
Setup the breakpoints and hit F5. The installation should start and stop at your breakpoint.
If you want to debug uninstallation of your Windows Service (.NET), use the “/u” argument of InstallUtil.exe.
If the debug session is aborted (because you stopped it in the middle or an error arose) , then the service might not be completely installed or removed. If that is the case, just open a command line window and type in:
>InstallUtil.exe /u <path:filename of your .NET executable>
Good debug session.