namespace TruckAP { using log4net; using log4net.Config; using System; using System.IO; using System.Reflection; using System.Windows.Forms; static class Program { private static ILog _log = LogManager.GetLogger(typeof(Program)); /// /// The main entry point for the application. /// [STAThread] static void Main() { LoadLog4netConfig(); _log.Info("AP Start"); string sSuffix = ""; string[] saCmd = Environment.GetCommandLineArgs(); foreach (string sCmd in saCmd) { if (sCmd == "-a" || sCmd == "-v") { sSuffix = sCmd; break; } } System.Threading.Mutex mu = new System.Threading.Mutex(true, string.Format("Global\\{0}{1}", typeof(Program).GUID, sSuffix), out bool IsAppRunning); if (!IsAppRunning) { _log.Error("Leave Program without doing anything(Mutex)"); mu.Dispose(); Environment.Exit(1); } _log.Info("Launch UI"); Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } private static void LoadLog4netConfig() { var repository = LogManager.CreateRepository( Assembly.GetEntryAssembly(), typeof(log4net.Repository.Hierarchy.Hierarchy) ); XmlConfigurator.Configure(repository, new FileInfo("Log4Net.config")); } } }