static void Main(string[] args) { var service = new ServiceMain(); if (args != null && args.Length > 0) { switch (args[0].ToUpper()) { case "-D": service.DebugMode(); return; } } ServiceBase.Run(service); }