【发布时间】:2015-09-23 06:26:07
【问题描述】:
我的问题如下: 当我尝试安装我的 Windows 服务时,我收到以下错误:
sn-p:
...
No public installers with the RunInstallerAttribute.Yes attribute could be found in the <path to exe> assembly.
...
我关注这个tutorial
我有一个Program.fs 文件,其中包含:
[<RunInstaller(true)>]
type public FSharpServiceInstaller() =
inherit Installer()
do
< some logic, doesn't really matter >
这应该足够了,事实上,我什至认为我不需要在类型定义中添加public关键字。使用InstallUtil.exe 安装这个可执行文件给了我与使用以下代码安装它相同的错误:
[<EntryPoint>]
let main args =
if Environment.UserInteractive then
let parameter = String.Concat(args);
match parameter with
| "-i" -> ManagedInstallerClass.InstallHelper [| Assembly.GetExecutingAssembly().Location |]
| "-u" -> ManagedInstallerClass.InstallHelper [| "/u"; Assembly.GetExecutingAssembly().Location |]
| _ -> printf "Not allowed!\n"
else
ServiceBase.Run [| new CreditToolsService() :> ServiceBase |];
0
我尝试以管理员和我的普通帐户在 PowerShell、cmd 和 Visual Studio CLI 中运行此脚本,但我一直收到相同的错误。如果有人知道我做错了什么,我将非常感谢一些帮助。
【问题讨论】:
-
感谢您的评论,非常感谢。我已经检查了相关问题,尽管操作员提出“相同”的问题,但没有答案;只是一个实现示例。
标签: f# windows-services service-installer