Jump to content
  • Advertisement
Sign in to follow this  
tshifhiwa

c# error

This topic is 3879 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!