title: "A timeout was reached while waiting for the service to connect" error after rebooting
body: <p>I have a custom-written Windows service that I run on a number of Hyper-V VMs. The VMs get rebooted a couple times an hour as part of some automated tests being run. The service is set to automatic start and almost all of the time, it starts up fine.</p>
  
  <p>However, maybe 5% of the time, with no pattern that I can discern, the service fails to start. When it fails, I get an error in Event Viewer saying </p>
  
  <blockquote>
    <p>A timeout was reached (30000 milliseconds) while waiting for the My Service Name service to connect.</p>
  </blockquote>
  
  <p>When this occurs, I can start the service manually, or restart again, and the service will start fine.</p>
  
  <p>The thing I can't figure out is that the 30 second timeout doesn't appear to be occurring in my code. The very first line of my service class's OnStart() method logs "Starting..." to its log4net log. When the service fails to start, I don't even get anything logged at all, which indicates to me that either log4net can't log for whatever reason, or the timeout is occurring before my OnStart() gets called.</p>
  
  <p>The service runs on a variety of OSes, from XP all the way up to Win7 and 2008R2, and I know that setting the service to delayed start may solve this for Vista and later, but that seems like a hack.</p>
  
  <p>I haven't been able to remote debug this because of the fact that it happens so intermittently and during system startup, and I'm at a loss as to further ways to try to figure out what's going on. Any ideas?</p>