除了service.StartType = ServiceStartMode.Automatic我的服务在安装后没有启动
解
在我的ProjectInstaller上插入此代码
protected override void OnAfterInstall(System.Collections.IDictionary savedState)
{
base.OnAfterInstall(savedState);
using (var serviceController = new ServiceController(this.serviceInstaller1.ServiceName, Environment.MachineName))
serviceController.Start();
}
Run Code Online (Sandbox Code Playgroud)
感谢ScottTx和Francis B.
安装Windows服务的唯一方法我知道是使用" Visual Studio 2008命令提示符 ",有没有办法在没有安装Visual Studio的机器上安装windows-service(假设.Net版本2.X是安装.)