title: Error 1053 after starting a Windows service
body: <p>I created a Windows Service installed with InstallUtil and started using the Services app ... I finally receive this error</p>
  
  <p><a href="https://i.stack.imgur.com/XSxo4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XSxo4.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/iSFh8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iSFh8.png" alt="enter image description here"></a></p>
  
  <p>But from this Log screen tells me that the service has started (in my service is a message that I write after it is connected to my databases)
  <a href="https://i.stack.imgur.com/BmUJx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BmUJx.png" alt="enter image description here"></a></p>
  
  <p>But on the services app the state is always "starting", I can not stop it because the service says "I can not receive messages"</p>
  
  <p>This is Program.cs class</p>
  
  <pre><code>static void Main(string[] args)
          {
              ServiceBase[] ServicesToRun;
              ServicesToRun = new ServiceBase[]
              {
                  new InterCompanyService()
              };
  #if DEBUG
              if (Environment.UserInteractive)
              {
                  const BindingFlags bindingFlags =
                      BindingFlags.Instance | BindingFlags.NonPublic;
  
                  foreach (var serviceBase in ServicesToRun)
                  {
                      var serviceType = serviceBase.GetType();
                      var methodInfo = serviceType.GetMethod("OnStart", bindingFlags);
  
                      new Thread(service =&gt; methodInfo.Invoke(service, new object[] { args })).Start(serviceBase);
                  }
  
                  return;
              }
  #endif
              ServiceBase.Run(ServicesToRun);
          }
  </code></pre>
  
  <p>Class Service</p>
  
  <pre><code>public InterCompanyService()
          {
              InitializeComponent();
  
  
              EventSourceCreationData escd = new EventSourceCreationData(eventLog.Source, eventLog.Log);
  
              if (!EventLog.SourceExists(eventLog.Source))
              {
                  EventLog.CreateEventSource(escd);
              }
          }
  </code></pre>
  
  <p>In OnStart I try to connect via EntityFramework to my DB</p>