I am working on a Windows service, and I would like to run the debugger and make breakpoints for the OnStart() method.
I have already add the line System.Diagnostics.Debugger.Launch();
in the OnStart method and breakpoints work perfectly for other methods like OnStop or the handler of the timer I set.
I tried to make breakpoints in my Onstart method and it seems like they are ignored, but the code I wrote works fine. To avoid this problem I wrote a log file for each breakpoints but I really want to make breakpoints as same as other situation.
This is my OnStart method (example):
protected override void OnStart(string[] args)
{
System.Diagnostics.Debugger.Launch();
WriteToFile("Service is started at " + DateTime.Now); // here I make breakpoint for test but it doesn't work
Timer.Elapsed += new ElapsedEventHandler(OnElapsedTime);
Timer.Interval = 20000; //number in milisecinds
Timer.Enabled = true;
}