Phillip Schmidt
Phillip Schmidt

Reputation: 8818

Cannot start service: The service is not responding to the control statement

I know this is a pretty common error, usually having to do with the onStart method of a windows service, but I can't figure out why this one isn't working.

Heres a stack trace of the error via windows event viewer:

at System.Diagnostics.EventLog.FindSourceRegistration(System.String, System.String, Boolean, Boolean)
   at System.Diagnostics.EventLog.SourceExists(System.String, System.String, Boolean)
   at System.Diagnostics.EventLog.SourceExists(System.String)
   at ArchivalPurgeService.ArchivalPurge..ctor()
   at ArchivalPurgeService.Program.Main()

and here is my program:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Timers;

namespace ArchivalPurgeService
{
    public partial class ArchivalPurge : ServiceBase
    {
        public ArchivalPurge()
        {
            try
            {
                InitializeComponent();
            }
            catch (Exception ex)
            {
            }
        }

        protected override void OnStart(string[] args)
        {
            try
            {
                timer2 = new Timer();
                timer2.Enabled = true;
                timer2.Interval = Convert.ToInt32(System.Configuration.ConfigurationSettings.AppSettings["RuntimeFrequency"]);
            }
            catch (Exception ex)
            {
            }
        }

        private Queue<Job> QueryDBForJobs()
        {   
            int i = 0;
            return new Queue<Job>();
        }

        protected override void OnStop()
        {

        }


        private void timer2_Elapsed(object sender, ElapsedEventArgs e)
        {
            QueryDBForJobs();
        }
    }
}

And I tried to run it even with everything commented out, and I'm getting the same issue. Could this just be a problem with the installation, maybe? I'm using an installer which I created almost exactly based on the MSDN how-to for creating windows services. I'm obviously also building/uninstalling/reinstalling after every code change.

Upvotes: 1

Views: 132

Answers (1)

Phillip Schmidt
Phillip Schmidt

Reputation: 8818

Apparently the issue was with the install, not the code. When I install via installutil everything works fine.

Upvotes: 1

Related Questions