Sign in to follow this  

c# error

This topic is 3668 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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) { }

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 3668 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this