Original Post
Hi am developing my window service I got this error OnStart(string[] args):no suitable method found to override and also on OnStop(string[] args):no suitable method found to override. I don’t know what to do below is my code namespace TestWindowsService1 { public partial class PollingService : ServiceBase { public PollingService() { InitializeComponent(); } public class pollingService { //keep track of worker thread. private Thread m_opollingThread = new Thread(new System.Threading.ThreadStart(pollProcess)); protected override void OnStart(string[] args) { // TODO: Add code here to start your service. //add code here to start your service. this method should set things //in motion so your service can do its work. eventLog1.WriteEntry("pollingSeervice is Starting."); //Start the thred. m_opollingThread.Start(); } protected override void OnStop() { // TODO: Add code here to perform any tear-down necessary to stop your service. EventLog1.WriteEntry("pollingSeervice is stopping."); //Stop the thred. m_opollingThread.Abort(); } private void PollProcess() { //Loops, until killed by OnStop. EventLog1.WriteEntry("PolingService service polling thred started."); do { //Wait... System.Threading.Thread.Sleep(30000); //30000 = 30 seconds PollingPass(); } while (true); } private void PollingPass() { try { //Do Stuff here... EventLog1.WriteEntry("pollingServices service polling pass executed."); } catch (System.Exception ex) { EventLog1.WriteEntry("PollingService encuntered an error '" + ex.Message + "'", EventLogEntryType.Error); EventLog1.WriteEntry("pollingService service stack trace: " + ex.StackTrace, EventLogEntryType.Error); } } private void EventLog1_EntryWritten(object sender, System.Diagnostics.EntryWrittenEventArgs e) { }