Wednesday, September 12, 2007

[C# 2.0] How To Debug, Install, Uninstall, Run, Stop A Windows Service

using System.Diagnostics;

protected override void OnStart(string[] args)
{

#if (DEBUG)
Debugger.Launch();
#endif

}


Tips to Install/Unistall/Run/Stop Windows Service using Visual Studio
From the menu, select Tool then External Tools, and add this item.


Title: Install Service
Command: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe
Arguments:
Initial directory: $(ProjectDir)/bin/debug

Title: Uninstall Service
Command: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe
Arguments: /u
Initial directory: $(ProjectDir)/bin/debug

Title: Run Service
Command: NET.exe
Arguments: START ""
Initial directory:

Title: Stop Service
Command: NET.exe
Arguments: STOP ""
Initial directory:

No comments: