Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing windows service fails: service already exists

I'm trying to reinstall a service I've written using C#. The first time this worked. I used installutil to handle the install and the service showed up in the list of services and I could start it. Then I made some updates to the code and uninstalled the service. After figuring out I had to close the services window, the service seemed to have disappeared (i.e. successfully uninstalled). However, upon trying to install the service again I got the message saying:

System.ComponentModel.Win32Exception: The specified service already exists

This seemed strange as I couldn't see it in the services window. I finally thought I found the problem after deleting a registry key regarding my service, but unfortunately this didn't solve anything.

Also, uninstalling again doesn't do much to solve the problem as this results in the contradictory message:

System.ComponentModel.Win32Exception: The specified service does not exist as an installed service

What should I believe? Does or doesn't the service exists? I feel like a physicist trying to figure out whether the cat is dead or alive. I hope someone here knows something to help solve this problem.

like image 415
Pieter Avatar asked Dec 03 '22 06:12

Pieter


1 Answers

A related SO-answer finally pointed me in the right direction (why I didn't find that in Google or SO's own search I don't know). Anyway, apparently the Designer.cs generated by Visual Studio also creates a process- and service-installer. Which of course install services with the same name as my manually created installers. Removing my own installers solved the problem.

like image 92
Pieter Avatar answered Dec 18 '22 00:12

Pieter