Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.WindowsService/3.3/ProjectInstaller.cs @ 6945

Last change on this file since 6945 was 6945, checked in by ascheibe, 12 years ago

#1233 slave: catch more errors and log them to the windows event log

File size: 992 bytes
Line 
1using System;
2using System.Collections;
3using System.ComponentModel;
4using System.ServiceProcess;
5
6
7namespace HeuristicLab.Clients.Hive.SlaveCore.WindowsService {
8  [RunInstaller(true)]
9  public partial class ProjectInstaller : System.Configuration.Install.Installer {
10    public ProjectInstaller() {
11      InitializeComponent();
12    }
13
14    protected override void OnAfterInstall(IDictionary savedState) {
15      base.OnAfterInstall(savedState);
16
17      //try to create an event log     
18      try {
19        if (!System.Diagnostics.EventLog.SourceExists("HLHive")) {
20          System.Diagnostics.EventLog.CreateEventSource("HLHive", "HiveSlave");
21        }
22      }
23      catch { }
24
25      //try to start the service after installation
26      using (var serviceController = new ServiceController(this.serviceInstaller1.ServiceName, Environment.MachineName)) {
27        try {
28          serviceController.Start();
29        }
30        catch { }
31      }
32    }
33  }
34}
Note: See TracBrowser for help on using the repository browser.