WCF服务托管
1.WindosService
使用topshelf安装windows服务
- 程序从nuget引入topshelf
- 服务端代码
var rc = HostFactory.Run(x => { x.Service<ServiceHost>(s => { s.ConstructUsing(name => new ServiceHost(typeof(Service3))); s.WhenStarted(tc => tc.Open()); s.WhenStopped(tc => tc.Close()); }); x.RunAsLocalSystem(); x.SetDescription("topshelf service3"); x.SetDisplayName("TopshelfService3"); x.SetServiceName("WcfServiceRestful3"); });
- 在根目录出执行 Host.exe install start (安装并启动命令)