views:

407

answers:

4

I'm trying to create my first Windows Service in C# VS2010 and slowly discover how I should do things. But now I have reached a point, where I cannot install a new version of my service. My setup program tells me

Error 1001. Service MyService was not found on computer '.'. --> The specified service does not exists as an installed service.

The last part of the message is translated into english from danish.

I cannot see the service in either the service list (services.msc), in the registry or in Add/Remove programs. I have removed the left overs from a previous installation, so no traces here either. I have emptied the temporary folder under my windows account.

Where do I locate the rest of the remains obstructing my installation of the service?

A: 

Have you tried the Add/Remove Programs? Incase you haven't already been there....here is a nice article on how to create a simple windows service from MSDN

James
@James: No, if only it was that simple. There is no trace of it in Add/Remove Programs either :|
Chau
@Chau: I had a lot of issues like this when I started working on services. When you do an install from your setup project I would advise you always do an uninstall from it aswell (don't remove files manually). Also you can set your project so you can do upgrades. As you have deleted the files manually (which will no doubt include the uninstaller) my advice would be to restart the machine and try again.
James
A: 

Did you initially install your service with a setup project, or just by using ServiceUtil from the framework folder? If you just want to run a new version of your service, it's as simple as stopping the existing service, replacing the EXE with your new one, and then starting the service again.

Does your service appear in the SERVICES.MSC list?

rwmnau
@rwmnau: I have done many things so far, and most of them probably very wrong :) As I stated, I cannot see any traces of my service in the system, nor can I install a new version - because it tells me that it cannot find an installed version on the computer. Very confusing message.
Chau
A: 

This is how I do it works every time:

Create a service and service installer as described in http://www.15seconds.com/issue/021007.htm, this seems old school, but the steps are the same in VS 2005, 2008 and 2010.

Once you have complied the service, to install it create the following cmd file (replace YOURSERVICE with the name of your service) and save it your bin folder.

for %%x in (%0) do set BatchPath=%%~dpsx
for %%x in (%BatchPath%) do set BatchPath=%%~dpsx

C:
cd %windir%
cd Microsoft.NET
cd Framework
cd v2*
installutil %BatchPath%YOURSERVICE.exe
NET START  YOURSERVICE

Open a command prompt and run the cmd.

To un-install create the following cmd file (replace YOURSERVICE with the name of your service) and save it your bin folder.

for %%x in (%0) do set BatchPath=%%~dpsx
for %%x in (%BatchPath%) do set BatchPath=%%~dpsx

NET STOP YOURSERVICE
SET ERRORLEVEL=0

c:
cd %windir%
cd Microsoft.NET
cd Framework
cd v2*
installutil -u %BatchPath%YOURSERVICE.exe

Open a command prompt and run the cmd.

DalSoft
+1  A: 

May be a little off topic, but... The msi installers for Windows Services are known for issues. You just re-discovered one of them. Because of miscount of GAC references by one of my prev msi installers, I actually had to advise my users to clean up their registries before I understood why they can't uninstall my service properly. This is what you are attempting to do. In general, not cool. Google for "msi issues". Check out http://installer.codeeffects.com/Default.aspx?HksJ48hGdr=c109 (the top point). Read more on other forums. Eventually, you'll find the solution to your particular problem but the journey won't be pleasant :)

Sasha