static void Main(string[] args) { var hostConfig = ObjectIOCFactory.GetSingleton <ServiceHostConfig>(); var commandArguments = new CommandArguments(args); if (commandArguments.ContainsArgument("service")) { hostConfig.Host.RunInService = true; } if (commandArguments.ContainsArgument("debug")) { hostConfig.App.Debug = true; } if (hostConfig.Host.RunInService) { ServiceBase.Run(new WinService()); } else { var exitHanlder = new ConsoleExitHanlder(); exitHanlder.Exit += new EventHandler((source, e) => applicationHost.Stop()); applicationHost = ApplicationHost.GetInstance(args); ObjectIOCFactory.GetSingleton <ApplicationHub>().Register(ObjectIOCFactory.GetSingleton <ApplicationContainer>()); applicationHost.Start(); ExecuteSystemCommand(); } }