I'm writing a Windows Service in C# (.NET 4).
Here is the code for the installer:
[RunInstaller(true)]
public partial class JobManagerInstaller : Installer
{
public JobManagerInstaller()
{
InitializeComponent();
this.Installers.Clear();
ServiceProcessInstaller serviceProcessInstaller = new ServiceProcessInstaller();
ServiceInstaller serviceInstaller = new ServiceInstaller();
EventLogInstaller eventLogInstaller = new EventLogInstaller();
// Service Account Information
serviceProcessInstaller.Account = ServiceAccount.LocalSystem;
serviceProcessInstaller.Username = null;
serviceProcessInstaller.Password = null;
// Service Information
// The installer's ServiceName must be identical to the JobManager.ServiceName set in the constructor of JobManager.cs
serviceInstaller.ServiceName = "VIAVista";
serviceInstaller.DisplayName = "VIAVista";
serviceInstaller.StartType = ServiceStartMode.Automatic;
// EventLog
eventLogInstaller.Source = "VIAVista";
eventLogInstaller.Log = "VIAVista";
// Dependency SQL Server service (i.e.SQL Server must run)
serviceInstaller.ServicesDependedOn = new string[] { "MSSQL$SQLEXPRESS" };
this.Installers.Add(serviceProcessInstaller);
this.Installers.Add(serviceInstaller);
this.Installers.Add(eventLogInstaller);
}
}
As you can see I want my event's source and log to be named "VIAVista".
When I try to install the service on my server (Windows Web Server 2008 R2 64bit) I'm told that the event source already exists in log "Application". That's weird since I thought this.Installers.Clear() would prevent creating a default source/log.
Info: I used regedit to make sure that there is no "VIAVista" key before installing the service.
Any ideas? Did I miss anything?
Try
serviceInstaller.Installers.Clear();