Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6551093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:17:40+00:00 2026-05-25T12:17:40+00:00

I have a Windows Service that I am trying to debug. Now it fails

  • 0

I have a Windows Service that I am trying to debug. Now it fails to start even though the current code used to work. The error is:

Windows could not start the MyService service on Local Computer

Error 1053: The service did not respond to the start or control
request in a timely fashion.

To isolate the error, I tried to comment out everything. The main method looks like this:

TextWriter tt = new StreamWriter(@"C:\startup.text", true);
tt.WriteLine("Starting up the service");
tt.Close();

ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[] 
   { 
       new MyService()
   };

TextWriter tt2 = new StreamWriter(@"C:\startup.text", true);
tt2.WriteLine("Run...");
tt2.Close();

It prints out both “Starting up the service” and “Run…” to the log file. I also stripped the inside of MyService so it’s empty. There is a try/catch around any code, which now is reduced to some log lines like above. I never enters the catch statement, which would have logged it.

Everything in OnStart has been commented out:

protected override void OnStart(string[] args)
{
}

So I’m basically out of ideas. I thought the error was because the Start method never finishes (or doesn’t within 30 seconds). Is there some other method that is called? Any ideas are appreciated.

Extra info: The constructor in MyService is empty. If I insert some Thread.Sleep(5000) lines, then it takes longer beofre the error message about Error 1053 pops up. The Main method seems to have to exit (without error).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T12:17:40+00:00Added an answer on May 25, 2026 at 12:17 pm

    You are missing ServiceBase.Run call:

    ServiceBase[] servicesToRun = new ServiceBase[]
                                    { 
                                        new MyService() 
                                    };
    ServiceBase.Run(servicesToRun);
    

    It might also be a good idea to subscribe to unhandled exceptions notification:

    static void Main() {
        ...
        AppDomain.CurrentDomain.UnhandledException 
                                          += CurrentDomain_UnhandledException;
        ...
    }
    
    private static void CurrentDomain_UnhandledException(
                                                     Object sender, 
                                                     UnhandledExceptionEventArgs e) {
    
        if (e != null && e.ExceptionObject != null) {
            // log exception:
        }
    }
    

    And add following try/catch to OnStart because .NET/SCM swallows exceptions:

    protected override void OnStart(String[] args) {
        try {
    
        } catch(Exception e) {
            // log exception:
            throw;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a windows service that has a lot of work to do simultaneously.
I have a Windows service running in local system that simply keeps trying to
I have a Windows Service (written in Java) that needs to start other Windows
I have a windows service that is failing to start, giving an error Error
I have a Windows service that runs as a logged-in user (local admin). During
I have a Windows Service that takes the name of a bunch of files
I have a windows service that generates logs as it does some execution. I
I have a windows service that receives a large amount of data that needs
I have a windows service that loads multiple handlers written by different developers. The
I have a windows service that has it's name set by an app.config. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.