public static bool Install()
{
Tracker.StartServer();
bool result = true;
InstallContext context = null;
try
{
using (var inst = new AssemblyInstaller(typeof (ServerLifecycleManager).Assembly, null))
{
context = inst.Context;
LogMessage("Installing service " + AppSettings.ServiceName, inst.Context);
IDictionary state = new Hashtable();
inst.UseNewContext = true;
try
{
inst.Install(state);
inst.Commit(state);
Tracker.TrackEvent(TrackerEventGroup.Installations, TrackerEventName.Installed);
}
catch (Exception err)
{
Tracker.TrackException("WindowsServiceManager", "Install", err);
try
{
inst.Rollback(state);
}
catch (Exception innerErr)
{
throw new AggregateException(new List<Exception> {err, innerErr});
}
throw;
}
}
}
catch (Exception ex)
{
result = false;
WriteExceptions(ex, context);
}
finally
{
Tracker.Stop();
}
return result;
}