2

我完全是开发 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);
    }
}
}

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

4

2 回答 2

5

您忘记指定基类

namespace ReviewsSvc 
{ 
    [RunInstaller(true)] 
    public class ReviewsSvcInstaller : Installer
    { 
        ....
于 2012-07-05T15:20:27.003 回答
1

确保主可执行文件 (EXE) 中的类ReviewSvcInstaller。安装程序在主入口程序集中查找此类。我希望它有所帮助。

于 2012-07-05T15:26:41.217 回答