0

WCF サービスがあり、installutil を使用してインストールしようとしています。そのため、インストールを実行すると以下のエラーが発生します。

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.

次に、ロールバックしてアンインストールします。

サービスと 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);
    }
}

どちらも同じネームスペースにあります。

また、WCF サービスのコンストラクターには、次の行があります。

    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";

何か案は?

4

0 に答える 0