Problem installing windows service

有些话、适合烂在心里 提交于 2019-12-05 06:41:47

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

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.

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