protected override void OnStart(string[] args) { try { System.IO.Directory.SetCurrentDirectory(System.AppDomain.CurrentDomain.BaseDirectory); HttpServer httpServer; httpServer = new MyHttpServer(Convert.ToInt32(ConfigurationManager.AppSettings["port"])); Thread thread = new Thread(new ThreadStart(httpServer.listen)); thread.Start(); Helper.WriteErrorLog("Service successfully started."); } catch (Exception e) { Helper.WriteErrorLog(e.ToString()); } }