Skip to main content
GameDev.net gamedev.net
🔒 Locked 🎮 Unity

c# error

Started by tshifhiwa Dec 4, 2007 at 2:15 AM 0 replies 1.1k views
Original Post
tshifhiwa
tshifhiwa
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) { }
Nyarlath
Nyarlath
Where is ServiceBase defined? You need a ServiceBase class with virtual OnStart and OnStop functions, defined in the TestWindowsService1 namespace.

If you delete the override keywords it will probably compile, but it will not work as expected.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.