static void Main(string[] args) { //ServiceBase[] ServicesToRun; //SelfHostService _selfHostService = new SelfHostService(); //_selfHostService.ServiceName = "foo"; //ServicesToRun = new ServiceBase[] //{ // _selfHostService //}; //ServiceBase.Run(ServicesToRun); AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;; var service = new SelfHostService(); service.ManualStart(args); var handle = GetConsoleWindow(); // Hide ShowWindow(handle, SW_HIDE); Console.WriteLine("Service started, press any key to kill"); Console.ReadKey(); //service.ManualStop(); //ServiceBase.Run(new ServiceBase[] { service }); AppDomain.CurrentDomain.UnhandledException -= CurrentDomain_UnhandledException; }
/// <summary> /// The main entry point for the application. /// </summary> static void Main() { ServiceBase[] ServicesToRun; SelfHostService _selfHostService = new SelfHostService(); _selfHostService.ServiceName = "WebAPI_Hosted"; ServicesToRun = new ServiceBase[] { _selfHostService }; ServiceBase.Run(ServicesToRun); }