2

I'm attempting to install the Windows Service I have written in F#, but I keep getting the following message when I run installutil:

No public installers with the RunInstallerAttribute.Yes attribute could be found in the C:\path\to\service\myservice.exe assembly.

The Windows service installer code is below. Note that both of the things which the error message claims are missing are, in fact, present:

  • ProjectInstaller is public.
  • ProjectInstaller is tagged/decorated with RunInstaller(true) attribute.

The service installer code:

module Project.WindowsService.Installer

open System.Configuration.Install
open System.ComponentModel
open System.ServiceProcess

[<RunInstaller(true)>]
type public ProjectInstaller () as installer =
    inherit Installer()

    // Define the process settings
    let processInstaller =
        new ServiceProcessInstaller(
            Account  = ServiceAccount.LocalSystem,
            Password = null,
            Username = null)

    // Define the service settings
    let serviceInstaller =
        new ServiceInstaller(
            ServiceName = "Project.WindowsService",
            DisplayName = "My Service",
            Description = "Blah. Blah, blah, blah. And, of course, blah.",
            StartType   = ServiceStartMode.Automatic)

    do
        // Define the installers
        [| processInstaller :> Installer
           serviceInstaller :> Installer |]
        |> installer.Installers.AddRange
Steven
  • 166,672
  • 24
  • 332
  • 435
Brad Collins
  • 846
  • 9
  • 18

2 Answers2

4

Turns out that putting the ProjectInstaller within a module is a problem: For some reason, installutil cannot find it.

Changing the module declaration:

module Project.WindowsService.Installer

... to a namespace declaration fixes everything:

namespace Project.WindowsService
Brad Collins
  • 846
  • 9
  • 18
  • 1
    It's because that installer class ends up as "nested class" in CLR terminology, and installutil only looks at top-level classes. – Fyodor Soikin Jun 29 '15 at 19:21
1

If you came to here from a search link then these two other post may be more relevant to you. In particular the 1st link below.

Install Windows Service created in Visual Studio

Unable to install windows service with the help of InstallUtil tool

Community
  • 1
  • 1
Sql Surfer
  • 1,344
  • 1
  • 10
  • 25