Gra*_* V. 2 c# installation windows-services
我在开发 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);
}
}
}
Run Code Online (Sandbox Code Playgroud)
我已经添加了必要的参考,但我仍然收到有关“未找到安装程序”的错误消息。我错过了什么?
你忘了指定基类
namespace ReviewsSvc
{
[RunInstaller(true)]
public class ReviewsSvcInstaller : Installer
{
....
Run Code Online (Sandbox Code Playgroud)