Problem Installing New Windows Service

(Not sure if this is the best forum, but I am using C# and did not see a forum for Windows Services).

I have just created a new Windows Service using C#, Visual Studio 2003, .NET 1.1 on my computer running Windows XP v5.1.

The whole thing compiles without any errors and when I installed it using installutil, all messages indicate that it was installed correctly. However, my new Windows Service does not display on the list of available services in the Control Panel> Administrative Tools>Services tool. I have hit the Refresh button many times and even rebooted my PC and it still does not show.

I then tried creating a setup project for it in Visual Studio. The setup project compiles and runs correctly with no sign of an error, but still nothing in the Services tool. Note that my service DOES show on the Control Panel> Add and Remove Programs listing. And if I try to install it again without un-installing, it gives me a 'Repair or Remove' prompt, so it knows it is there. I have uninstalled/reinstalled, refreshed, and rebooted several times and it still does not show in the Services listing! !

Any ideas as to what could be the problem



Answer this question

Problem Installing New Windows Service

  • Beast Forever

    Check over the output from installutil very closely. The difference between ‘success’ and ‘failed’ is not very great in the messages.

    Bruce Johnson [C# MVP]
    http://www.objectsharp.com/blogs/bruce


  • wavesmash

    If it has a Stop method, it does not appear to be exposed because I don't see it as an option. There is an event handler for handling a Stop event (OnStop) but I don't see anything for triggering one.
  • Schnecke

    Did you create an installer class in your service's assembly Does it include ServiceInstaller and ServiceProcessInstaller sub-components
  • Jimbolino

    The ServiceBase class, the class you should be deriving from, has a Stop method. I've never made a service that can shut itself down, but I would guess that calling that method would be the clean way to shut it down.
  • VitalyT

    That was the issue. The example that I was following from the web did not include or mention the installer class. I added one in and it now installs correctly and displays on the Services listing. Odd that there was no errors or warnings when I did not have it.

    Next Windows Service issue... I want my Windows Service to stop itself under certain circumstances. I have seen a few web sites that recommend using the Environment.Exit command. This does shut down the service alright, but it throws a big ugly error message and adds an error msg to the event log.

    Anybody know of a cleaner way to have a Windows Service shut itself down

    Thanks!


  • Kutijevac

    Are you certain of the name you gave to the service There are two properties, the service name and the Display Name. Perhaps your service was installed under a name you were not expecting

    Just a thought

  • Problem Installing New Windows Service