When you want to debug your own written Windows Service, you have to install the service on your local machine and attach the Visual Studio 2005 debugger to the process.
There is an easy way to start (and test) the windows service within Visual Studio 2005.
1) Add a public method to your windows service class to invoke the protected OnStart :
public void OnStart()
{
this.OnStart(null);
}
2) Add a new class to your windows service project
public class Entry
{
static void Main()
{
#if DEBUG
MediationService myService = new MediationService();
myService.OnStart();
System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
#endif
}
}
3) Set the Startup object in the properties window of your project to the new Entry class
4) Set your breakpoint wherever you want and start debugging directly from Visual Studio 2005