Answered by:
windows service did not respond to the start or control request in a timely fashion

Question
-
Hi,
I have created a simple windows service (using topshelf) which writes text to event log . Service works perfectly from Visual Studio Express 2012 but after installing it an clicking on start it gives me an error :1053 The service did not respond to the start or control request in a timely fashion. After that status of the service is start pending. I tried to run the service both as local system (with or without desktop cooperation) and user with admin privileges.
I have already tried solutions from other topics but nothing seems to useful.
Below you may see the code :
public class Test { public void Start() { try { Console.WriteLine("Start"); Execute(); } catch (Exception ex) { Console.WriteLine(ex.Message); } } public void Stop() { try { Console.WriteLine("Stop "); } catch (Exception ex) { Console.WriteLine(ex.Message); } } public void Execute() { EventLog _log = new EventLog(); _log.Source = "123Test"; try { while (true) { _log.WriteEntry("sleeping ..." + System.DateTime.Now.ToString()); Thread.Sleep(5000); } } catch (Exception e) { Console.WriteLine("error: " + e.Message.ToString()); } } } public class Program { public static void Main() { try { HostFactory.Run(x => { x.Service<Test>(s => { s.ConstructUsing(name => new Test()); s.WhenStarted(test => test.Start()); s.WhenStopped(test => test.Stop()); }); x.RunAsLocalSystem(); x.SetDisplayName("123Test"); x.SetServiceName("123Test"); }); } catch (Exception ex) { EventLog.WriteEntry("123Test", ex.ToString(), System.Diagnostics.EventLogEntryType.Error); } } }
I would appreciate any suggestion that may lead to solving this problem.
Edit: (OS - Win7)- Edited by BukajResalg Thursday, May 16, 2013 10:06 AM
- Moved by Santosh Bhandarkar Thursday, May 16, 2013 11:29 AM Moved from Server General forum
Thursday, May 16, 2013 10:02 AM
Answers
-
Hello,
for programming questions please ask in one from http://social.msdn.microsoft.com/Forums/en-US/categories There are the code experts.
Best regards
Meinolf Weber
MVP, MCP, MCTS
Microsoft MVP - Directory Services
My Blog: http://msmvps.com/blogs/mweber/Disclaimer: This posting is provided AS IS with no warranties or guarantees and confers no rights.
- Proposed as answer by Santosh Bhandarkar Thursday, May 16, 2013 11:28 AM
- Marked as answer by Just Karl Thursday, May 23, 2013 2:19 PM
Thursday, May 16, 2013 11:16 AM
All replies
-
Hello,
for programming questions please ask in one from http://social.msdn.microsoft.com/Forums/en-US/categories There are the code experts.
Best regards
Meinolf Weber
MVP, MCP, MCTS
Microsoft MVP - Directory Services
My Blog: http://msmvps.com/blogs/mweber/Disclaimer: This posting is provided AS IS with no warranties or guarantees and confers no rights.
- Proposed as answer by Santosh Bhandarkar Thursday, May 16, 2013 11:28 AM
- Marked as answer by Just Karl Thursday, May 23, 2013 2:19 PM
Thursday, May 16, 2013 11:16 AM -
Sorry,
Please close this thread, have already open new one in a proper category.Thursday, May 16, 2013 11:45 AM