-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathProgram.cs
More file actions
41 lines (40 loc) · 1.65 KB
/
Copy pathProgram.cs
File metadata and controls
41 lines (40 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;
using log4net.Config;
using SimpleServices;
namespace RunFor591
{
[RunInstaller(true)]
public class Program : SimpleServiceApplication
{
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// 應用程式的主要進入點。
/// </summary>
private static void Main(string[] args)
{
System.AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionTrapper;
XmlConfigurator.Configure(new System.IO.FileInfo(AppDomain.CurrentDomain.BaseDirectory + "\\log4net.config"));
new Service(args, new List<IWindowsService> {new RunFor591Service()}.ToArray
,
installationSettings: (serviceInstaller, serviceProcessInstaller) =>
{
serviceInstaller.ServiceName = "RunFor591";
serviceInstaller.StartType = ServiceStartMode.Automatic;
serviceProcessInstaller.Account = ServiceAccount.LocalService;
},
configureContext: x => { x.Log = Console.WriteLine; })
.Host();
}
static void UnhandledExceptionTrapper(object sender, UnhandledExceptionEventArgs e)
{
Console.WriteLine(e.ExceptionObject.ToString());
log.Error(e.ExceptionObject);
}
}
}