0

I have a WCF service and I am trying to install it using installutil, so when performing the installation below errors are raised:

The service MyService has been installed correctly.
Creating the EventLog source MyService in the Application Registry...

Exception during the installation phase.
System.ArgumentException: The source code MyService already exists in the local machine.

Then it rollback and uninstall it.

I have below classes to install service and EventLog:

[RunInstaller(true)]
public class MyEventLogInstaller : Installer
{
    private EventLogInstaller myEventLogInstaller;

    public MyEventLogInstaller()
    {
        //Create Instance of EventLogInstaller
        this.myEventLogInstaller = new EventLogInstaller();

        // Set the Source of Event Log, to be created.
        this.myEventLogInstaller.Source = "TEST";

        // Set the Log that source is created in
        this.myEventLogInstaller.Log = "Application";

        // Add myEventLogInstaller to the Installers Collection.
        Installers.Add(this.myEventLogInstaller);
    }
}

[RunInstaller(true)]
public class ProjectInstaller : Installer
{
    private ServiceProcessInstaller process;
    private ServiceInstaller service;

    public ProjectInstaller()
    {
        this.process = new ServiceProcessInstaller();
        this.process.Account = ServiceAccount.LocalSystem;
        this.service = new ServiceInstaller();
        this.service.ServiceName = "MyService";
        Installers.Add(process);
        Installers.Add(service);
    }
}

They are both in the same namespace.

Also in the constructor of the WCF Service I have the following lines:

    if (!System.Diagnostics.EventLog.SourceExists("TEST"))
    {
        System.Diagnostics.EventLog.CreateEventSource("TEST", "Application");
    }

    this.eventLog = new System.Diagnostics.EventLog();
    this.eventLog.Source = "TEST";
    this.eventLog.Log = "Application";

Any ideas?

Willy
  • 9,848
  • 22
  • 141
  • 284
  • According to the error message your service is already installed. Check "Services" in Control Panel whether it is there or not. If yes, you must remove first. – Andras Sebo Jun 25 '13 at 09:37
  • 1
    Finally I have solved it by setting service.DisplayName and service.ServiceName to be equal to service.DisplayName. – Willy Jun 25 '13 at 19:16
  • @user1624552, consider answering your own question with your solution and marking it as the accepted answer. – Fernando Carvalhosa Jul 27 '15 at 19:21

0 Answers0