You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

59 lines
1.8 KiB

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));
/// <summary>
/// The main entry point for the application.
/// </summary>
[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"));
}
}
}