Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WCF服务:创建事件日志时发生InstallUtil错误_Wcf_Installutil - Fatal编程技术网

WCF服务:创建事件日志时发生InstallUtil错误

WCF服务:创建事件日志时发生InstallUtil错误,wcf,installutil,Wcf,Installutil,我有一个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 c

我有一个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.
然后它回滚并卸载它

我有以下类来安装服务和事件日志:

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

有什么想法吗?

根据错误消息,您的服务已安装。检查控制面板中的“服务”是否存在。如果是,必须先删除。最后,我通过设置Service .DePosiNeNd和Service .Service NeNe来解决这个问题。Service No.PrsieNo.@ USS162452,考虑用解决方案回答您自己的问题,并将其标记为已接受的答案。