static void Main(string[] args) { SqlDataSource.DisableCustomQueryValidation = true; XpoDefault.TrackPropertiesModifications = true; //SafePostgreSqlConnectionProvider.Register(); var connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; XpoDefault.DataLayer = XpoDefault.GetDataLayer(connectionString, AutoCreateOption.SchemaAlreadyExists); SimpleDataLayer.SuppressReentrancyAndThreadSafetyCheck = true; //{ "Reentrancy or cross thread operation detected. To suppress this exception, set DevExpress.Xpo.SimpleDataLayer.SuppressReentrancyAndThreadSafetyCheck = true"} var culture = new CultureInfo("en-US") { DateTimeFormat = { ShortDatePattern = "dd.MM.yyyy", LongDatePattern = "dd.MM.yyyy HH:mm", LongTimePattern = "HH:mm" } }; Thread.CurrentThread.CurrentCulture = culture; DevExpress.Utils.FormatInfo.AlwaysUseThreadFormat = true; //CultureInfo.DefaultThreadCurrentCulture = culture; AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; AppDomain.CurrentDomain.FirstChanceException += CurrentDomain_FirstChanceException; var debugMode = Debugger.IsAttached; if (args.Length > 0) { for (var ii = 0; ii < args.Length; ii++) { switch (args[ii].ToUpper()) { case "/NAME": if (args.Length > ii + 1) { InstallServiceName = args[++ii]; } break; case "/I": InstallService(); return; case "/U": UninstallService(); return; case "/D": debugMode = true; break; default: break; } } } if (debugMode) { var service = new Program(); service.OnStart(null); Console.WriteLine("Service Started..."); Console.WriteLine("<press any key to exit...>"); Console.Read(); } else { var program = new Program(); ServiceBase.Run(program); } }
static void RunAsService() { ServiceBase[] servicesToRun; servicesToRun = new ServiceBase[] { new MainService() }; ServiceBase.Run(servicesToRun); }