我是开发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);
}
}
}
我添加了必要的参考资料,但我仍然收到有关“未找到安装程序”的错误消息。我错过了什么?
答案 0 :(得分:4)
您忘了指定基类
namespace ReviewsSvc
{
[RunInstaller(true)]
public class ReviewsSvcInstaller : Installer
{
....
答案 1 :(得分:1)
确保主可执行文件(EXE)中的类 ReviewsSvcInstaller 。安装程序在主条目程序集中查找此类。我希望它有所帮助。