13
votes

I use VS 2012 and since the setup projects have been removed from it I have to use InstallUtil.exe.

I don't have projectInstaller class in my windows service app. I run in command prompt:

installutil FilesMonitoringService.exe 

I get:

C:\Program Files\Microsoft Visual Studio 8\VC#>installutil "C:\Program Files\Mic rosoft Visual Studio 8\VC#\CSharpProjects\MyService\MyService\bin\Release\MyServ ice.exe" Microsoft (R) .NET Framework Installation utility Version 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved.

Running a transacted installation.

Beginning the Install phase of the installation. See the contents of the log file for the C:\Program Files\Microsoft Visual Studi o 8\VC#\CSharpProjects\MyService\MyService\bin\Release\MyService.exe assembly's progress. The file is located at C:\Program Files\Microsoft Visual Studio 8\VC#\CSharpProj ects\MyService\MyService\bin\Release\MyService.InstallLog. Installing assembly 'C:\Program Files\Microsoft Visual Studio 8\VC#\CSharpProjec ts\MyService\MyService\bin\Release\MyService.exe'. Affected parameters are: logtoconsole = assemblypath = C:\Program Files\Microsoft Visual Studio 8\VC#\CSharpProjects\ MyService\MyService\bin\Release\MyService.exe logfile = C:\Program Files\Microsoft Visual Studio 8\VC#\CSharpProjects\MySer vice\MyService\bin\Release\MyService.InstallLog No public installers with the RunInstallerAttribute.Yes attribute could be found in the C:\Program Files\Microsoft Visual Studio 8\VC#\CSharpProjects\MyService\ MyService\bin\Release\MyService.exe assembly.

The Install phase completed successfully, and the Commit phase is beginning. See the contents of the log file for the C:\Program Files\Microsoft Visual Studi o 8\VC#\CSharpProjects\MyService\MyService\bin\Release\MyService.exe assembly's progress. The file is located at C:\Program Files\Microsoft Visual Studio 8\VC#\CSharpProj ects\MyService\MyService\bin\Release\MyService.InstallLog. Committing assembly 'C:\Program Files\Microsoft Visual Studio 8\VC#\CSharpProjec ts\MyService\MyService\bin\Release\MyService.exe'. Affected parameters are: logtoconsole = assemblypath = C:\Program Files\Microsoft Visual Studio 8\VC#\CSharpProjects\ MyService\MyService\bin\Release\MyService.exe logfile = C:\Program Files\Microsoft Visual Studio 8\VC#\CSharpProjects\MySer vice\MyService\bin\Release\MyService.InstallLog No public installers with the RunInstallerAttribute.Yes attribute could be found in the C:\Program Files\Microsoft Visual Studio 8\VC#\CSharpProjects\MyService\ MyService\bin\Release\MyService.exe assembly. Remove InstallState file because there are no installers.

The Commit phase completed successfully.

The transacted install has completed.

C:\Program Files\Microsoft Visual Studio 8\VC#>

OK, seems like everything have been installed. But! When I go to task manager to the Services page I can't find my service.

What could be the reason?

Thanks in advance!

Edits: I pointed out that I don't have projectInstaller class because if I add it (in designer -> add installer) and run installutil command I get: (approximate translation)

Installation of FilesMonitoringService... Creation of EventLog FilesMonitoringService in a log jornal Application...

On this setup stage the exception occured.

System.Security.SecurityException: The source is not found, but failed to find by any or all log jornals. Not available jornals: Security.

The recoil stage starts.

// lots of text

The recoil stage has succeded

Setup group operation executed. Setup failed and recoil was executed.

So, if I add projectInstller to my windows service it definitely fails to install with installUtil.
Here is the generated code:

[RunInstaller(true)]
public partial class ProjectInstaller : Installer
{
    public ProjectInstaller()
    {
        InitializeComponent();
    }
    private void serviceInstaller1_AfterInstall(object sender, InstallEventArgs e)
    {}
    private void serviceProcessInstaller1_AfterInstall(object sender, InstallEventArgs e)
    {}
}

Mabby I need to put some code into afterInstall methods? I also set this properies in a properties window:

serviceInstaller1: ServiceName -> FileMonitoringService, StartType -> Automatic
serviceProcessInstaller1: Account -> LocalSystem

Or can it be implemented without projectInstaller?

3
2017 Comment - This subject has several useful answers and comments at this similar SO post. stackoverflow.com/questions/7922105/…Sql Surfer

3 Answers

18
votes

Ok, there are couple of things:

1) You need projectInstaller.
2) YourProject -> properties; Startup project -> YourProject.Program
3) build
4) “Run as Administrator” the command prompt!

Everything works now.

complete tutorial link

1
votes

I don't have a copy of VS2012 to test it now, but I believe that your problem has something to do with the

I don't have projectInstaller class in my windows service app

part.

From msdn:

Installation components register an individual service on the system to which it is being installed and let the Services Control Manager know that the service exists

0
votes

It seems trivial, but check carefully when you are writing the installutill arguments, because you could confuse the exe file of the service with another exe file generated by the compilation of a referenced project (that has no service installers) and make it fail.