public void InitDomain() { Domain = AppDomain.CreateDomain(FriendlyName, null, Setup); Domain.UnhandledException += (sender, e) => { "捕获了漏掉的异常".Log(); e.ExceptionObject.ToString().Log(); }; Domain.ProcessExit += (sender, e) => { LogExtends.Finally(); }; }
/// <summary> /// 应用程序的主入口点。 /// </summary> static void Main() { AppDomain.CurrentDomain.UnhandledException += (sender, e) => { "捕获了漏掉的异常".Log(); e.ExceptionObject.ToString().Log(); }; AppDomain.CurrentDomain.ProcessExit += (sender, e) => { LogExtends.Finally(); }; ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new DotnetService() }; ServiceBase.Run(ServicesToRun); }
protected override void OnStop() { "服务停止".Log(); LogExtends.Finally(); }