Wednesday, March 10, 2010

Debugging a Windows Service without installing

Well, first, to install using installutil [myapp.exe], you must put an environment variable in your system. -> InstallUtil.exe is in Microsoft.NET folder.

Visual Studio 2008 will not let you Debug a windows service. In the Project Properties, in the Debug tab, put [some command line argument...like /c for console]. This will send a command line argument to your application.

Surround the

ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new MainDataService()
};

ServiceBase.Run(ServicesToRun);

With an

if(commandLineArg == "/c")
{
[code above]
}

This will run your application in Visual Studio

No comments:

Post a Comment