除了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();
}
感谢ScottTx和FrancisB。