Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
468 views
in Technique[技术] by (71.8m points)

.net 2.0 - Starting a windows service fails with error 1053

I have a windows service that is failing to start, giving an error "Error 1053: The service did not respond to the start or control request in a timely fashion".

Running the service in my debugger works fine, and if I double click on the the service .exe on the remote machine a console window pops up and continues to run without problem - I can even see log messages showing me that the program is processing everything the way it should be.

The service had been running fine previously, though this is my first time, personally, trying to deploy it with the most recent changes made to the program. I've evaluated those changes and cant figure out how they might cause this problem, particuarly since everything runs fine when not started as a service.

The StartRoutine() method of the service impelmentation is empty, so should be returning in a "timely fashion".

I've checked the event logs on the computer, and it doesn't give any additional information other than it didn't hear back from the service in the 30 second requisite time frame.

Since it works on my machine, and as a double-clicked executable, how would I go about figuring out why it fails as a service?

Oh, and it's .NET 2.0, so it shouldn't be affected by the 1.1 framework bug that exhibited this symptom (http://support.microsoft.com/kb/839174)

The box is a windows server 2003 R2 machine running SP2.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This is a misleading error. It's probably an unhandled exception.

Empty your OnStart() handler then try this in your constructor...

    public MainService()
    {
        InitializeComponent();

        try
        {
            // All your initialization code goes here.

            // For instance, my exception was caused by the lack of registry permissions
            ;
        }
        catch (Exception ex)
        {
            EventLog.WriteEntry("Application", ex.ToString(), EventLogEntryType.Error);
        }
    }

Now check the EventLog on your system for your Application Error.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...