1

.Net 3.5

I've built into the service exe the ability for it to install itself using a -i feature. I have a custom installer class and am using a common technique on found online here. That installer class basically has it's own service and serviced process installer.

This code has worked well for a very long time. Finally ran into a Win 7 64 bit machine were it refuses to install.

Basically, the log shows it's installing the service and that succeeds. Then it tries to create an event log and that fails with

An exception occurred during the Install phase. System.ComponentModel.Win32Exception: The specified service already exists

I just got done having the OS completely reinstalled from scratch, first thing I did was try to install as a service, and it's the same error. Why is it thinking that event log is already there?

I've already read all the other posts and I've browsed my registry and there is nothing in there for my service or event log. I have full admin rights, when I try to open cmd as administrator, it doesn't even prompt me, so as far as I can tell, I am an admin (I can see that in my user profile).

I even added code to check to see if it found the EventLog using System.Diagnostics.EventLog.SourceExists which does report it found it, and so I added a call to System.Diagnostics.EventLog.DeleteEventSource but that doesn't help.

I even tried removing the EventLog installer from the ServiceInstaller, but then it starts failing for other reasons.

Any ideas?

Here is some sample code for an alternate installer I tried that I found here with the same results:

public partial class Service1Installer : Installer
{
    public Service1Installer()
    {
        InitializeComponent();
        ServiceProcessInstaller process = new ServiceProcessInstaller();
        process.Account = ServiceAccount.LocalSystem;

        ServiceInstaller serviceAdmin = new ServiceInstaller();
        serviceAdmin.StartType = ServiceStartMode.Manual;
        serviceAdmin.ServiceName = "Service1";
        serviceAdmin.DisplayName = "Service1";
        serviceAdmin.Description = "Service1";

        Installers.Add(serviceAdmin);
        Installers.Add(process );
    }
}
Community
  • 1
  • 1
happyfirst
  • 1,033
  • 1
  • 13
  • 27
  • Does changing the name of the "event source" work? – Raj Ranjhan Feb 23 '12 at 20:42
  • Have you checked what platform target is set (Project Properties) i.e. Any/x86/x64? For the EventLog, can you wrap the attempt at logging in a try-catch and if it fails try writing to a text file? Are you using a custom source? If so, try just using Application – kaj Feb 23 '12 at 20:52
  • Can you compile the service with TRACE enabled and get a line number where the error occurs? I have a feeling that error has nothing to do with logging. – Hand-E-Food Feb 23 '12 at 21:43
  • Tried changing the name of the EventSource, no luck. It's compiled for AnyCPU. Not using a custom source. – happyfirst Feb 24 '12 at 14:25
  • So I setup a Windows 7 64 bit VM and same problem. Just won't install. Installs the service, then tries to create event log, and complains it already exists. – happyfirst Feb 29 '12 at 20:14

3 Answers3

1

uninstall your service

  installutil /u yourproject.exe

restart your machine

http://msdn.microsoft.com/en-us/library/sd8zc8ha(v=vs.80).aspx

let me know if you still have a issue

Micah Armantrout
  • 6,781
  • 4
  • 40
  • 66
  • I've already tried this many times. I even reinstalled the OS!. System.ComponentModel.Win32Exception: The specified service does not exist as an installed service. TWICE. Once for the service and once for the event log. I really really hate how enter defaults to sbmitting in these comments. And then when I reinstall (even after a reboot), it's happy installing the service but then fails at the eventlog part, saying the eventlog is already there. – happyfirst Feb 24 '12 at 14:20
  • and if you install it says An exception occurred during the Install phase. System.ComponentModel.Win32Exception: The specified service already exists Correct ? did you try @LemonBegalge Suggestion ? – Micah Armantrout Feb 24 '12 at 14:24
  • Yes, I tried his suggestion. I get the error you stated, but NOT on the service part of the install, but during the EventLog part of the install. – happyfirst Feb 24 '12 at 14:27
  • Try deleting the custom event source out of the registry http://stackoverflow.com/questions/127936/deleting-custom-event-log-source-without-using-code then reinstall the service – Micah Armantrout Feb 24 '12 at 14:52
  • Already tried that. There is no event source in their with my name. Basically, based on everything I've read, my service is NOT installed and there is not event log. Then I run the install to install the service, which first installs the service, then sets up the event log, and now, it fails because it sees an event log. Only thing I can think of is that Win7-64 is creating an eventlog in the first step. NOTE, my installer is barebones. I didn't customize it. Whatever eventlog is trying to get installed, it's coming out of the base class. – happyfirst Feb 24 '12 at 15:06
0

In the end, my problem was our internal installer. I commented it out and now just install the service from the command line and it now installs on 64 bit OS. Still don't know why it would work before on 32 bit.

happyfirst
  • 1,033
  • 1
  • 13
  • 27
0

Use installutil as @MicahArmantrout mentions, if the exe still resides on disk.

Otherwise, open a commandline as Administrator and execute: sc delete "my service name"

jglouie
  • 12,523
  • 6
  • 48
  • 65