gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 07:54:26 24 4
gpt4 key购买 nike

我正在尝试安装用 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com