Problem installing windows service

喜夏-厌秋 提交于 2019-12-07 01:24:48

问题


I am having a problem installing a Windows service. I installed and uninstalled the service numerous times (installutil..... installutil /u) without any problem but something went wrong and now when I attempt to install, I get the error message listed below. I checked the computer management console, and service CIMediator does not appear on the list of services. How do I remove the service?

System.ArgumentException: Source CIMediator already exists on the local computer.


回答1:


Just solved the same problem, also after a numerous uninstalls/installs/restarts. I have my own implementation of service installer (derived from [System.Configuration.Install.Installer][1]), and I have specified application EventLog as following:

    public ProjectInstaller()
    {
        InitializeComponent();

        EventLogInstaller installer = FindInstaller(this.Installers);
        if (installer != null)
        {
            installer.Log = "MyService";                 
        }
    }       

You might have the same feature implemented the following way ([MSDN: EventLog.CreateEventSource Method] [2]):

if(!EventLog.SourceExists("MySource"))
{
    EventLog.CreateEventSource("MySource", "MyNewLog");
}

In my case, during some of the installs EventLog was successfuly created, but during uninstall something went wrong, and EventLog was not removed (although it was not displaying in EventViewer, it was still present in the registry). So the error "MyService already exists on the local computer", was obviously error about EventLog, not the service itself.

You could try to do the following:

Go to your Start menu and type regedit. This will open Registry Editor. Be careful with it, it is always recommended to back up the whole registry before doing anything (File -> Export), or only the keys you are about to edit/delete. Open Edit -> Find , type CIMediator and leave only Keys checked. Your service name should appear as key multiple times, on following locations

HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\services\eventlog\CIMediator,
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\services\CIMediator,
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\eventlog\CIMediator,
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\CIMediator

Try to delete these keys. It worked for me.

1 2




回答2:


Check to see if the key is still there in the registry.

HKLM\System\CurrentControlSet\Services\CIMediator (probably, unless the key is defined differently)

If it is, export the key to a .reg file and then delete it.



来源:https://stackoverflow.com/questions/4824051/problem-installing-windows-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!