c# - 当前上下文中不存在名称 'Installers'

标签 c# windows-services installation

我在开发 Windows 服务方面完全是菜鸟,我找到了一个关于实现标准 Windows 服务的教程。这是我找到的代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Configuration.Install;
using System.ServiceProcess;

namespace ReviewsSvc
{
[RunInstaller(true)]
public class ReviewsSvcInstaller
{
    private ServiceProcessInstaller processInstaller;
    private ServiceInstaller serviceInstaller;

    public ReviewsSvcInstaller()
    {
        processInstaller = new ServiceProcessInstaller();
        serviceInstaller = new ServiceInstaller();

        processInstaller.Account = ServiceAccount.LocalSystem;
        serviceInstaller.StartType = ServiceStartMode.Manual;
        serviceInstaller.ServiceName = "Reviews Updater";
        Installers.Add(serviceInstaller);
        Installers.Add(processInstaller);
    }
}
}

我已经添加了必要的引用资料,但我仍然收到有关未找到“安装程序”的错误消息。我错过了什么?

最佳答案

你忘了指定基类

namespace ReviewsSvc 
{ 
    [RunInstaller(true)] 
    public class ReviewsSvcInstaller : Installer
    { 
        ....

关于c# - 当前上下文中不存在名称 'Installers',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11347353/

相关文章:

c# - 可以在 C# 应用程序中执行实时多 channel 音频卷积吗?

c# - 请求 ["key"] 与 Request.Params ["key"] 与 Request.QueryString ["key"]

c# - 使用C#中的处理计算直线中有多少曲线进入图像

c# - CreateProcessAsUser : Service gets "5: Access Denied" trying to access network share

python - 如何更改 Anaconda 的默认目录?

terminal - 通过 Docker 安装 OpenFOAM

linux - zImage 安装在 Raspberry PI 2 上

c# - 在内存中复制或加载 sqlite 数据库? C#?

java - 将java作为windows服务运行的简单灵活的方法

windows-services - ConfigurationErrorsException : Unable to load type . .. 因为它不是公开的