static void Main(string[] args) { // Read log4net configuration. using (Stream stream = Assembly.GetEntryAssembly().GetManifestResourceStream("Echo.Server.log4net.config")) { log4net.Config.XmlConfigurator.Configure(LogManager.CreateRepository(Assembly.GetEntryAssembly(), typeof(log4net.Repository.Hierarchy.Hierarchy)), stream); } Log.InfoFormat("Starting runtime model and engine v{0}", Assembly.GetEntryAssembly().GetName().Version); Log.InfoFormat("Server process started [PID:{0}]", Process.GetCurrentProcess().Id); // TODO: How to handle UnhandledException? //AppDomain.CurrentDomain.UnhandledException += OnUnhandledException; SetConsoleCtrlHandler(new ProcessEventHandler(OnProcessEvent), true); try { Server = new Echo.Runtime.Engine.Server(); Log.Info("Server runtime engine instantiated"); Server.Configure(); Server.Start(); Server.WaitForExit(); } catch (Exception e) { Log.Error(e); throw; } if (Server != null) { Server.Dispose(); } Log.InfoFormat("Server process ended [PID:{0}]", Process.GetCurrentProcess().Id); }