f# - 在 F# : "No public installers with the RunInstallerAttribute.Yes attribute ..." 中安装 Windows 服务

标签 f# windows-services

我正在尝试安装用 F# 编写的 Windows 服务,但在运行 installutil 时不断收到以下消息:

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

Windows 服务安装程序代码如下。请注意,错误消息声称缺少的两件事实际上都存在:

  • ProjectInstaller 是公开的。
  • ProjectInstaller 使用 RunInstaller(true) 属性进行标记/修饰。

服务安装程序代码:

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

最佳答案

事实证明,将 ProjectInstaller 放入模块中是一个问题:由于某种原因,installutil 无法找到它。

更改模块声明:

module Project.WindowsService.Installer

...命名空间声明修复了所有问题:

namespace Project.WindowsService

关于f# - 在 F# : "No public installers with the RunInstallerAttribute.Yes attribute ..." 中安装 Windows 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31123025/

相关文章:

.net - Windows 安装程序 : Error 1001, CustomAction _xxxxx.install 返回实际错误代码 1603

azure - 在 F# Azure Functions 项目中共享代码

c# - 是否有可能完全用托管 .NET 语言编写 JIT 编译器(针对 native 代码)

f# - 通过查找 bigint 来扩展 F# 数组

.net - windows服务-配置文件

vb.net - window 服务

c# - 如何以管理员权限启动 Windows 服务

c# - 在 Windows 10 中部署 Windows Phone 8.1 应用程序时找不到 IpOverUsbSvc

f# - 在 F# 中覆盖 ToString 时避免堆栈溢出

f# - "point free"风格在函数式编程中的优缺点是什么?