WCF服务托管

1.WindosService 

使用topshelf安装windows服务

    1. 程序从nuget引入topshelf
    2. 服务端代码
       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");
                  });
    3. 在根目录出执行 Host.exe install start (安装并启动命令)

 

2.Console

3.IIS

4.Winform/WPF

posted @ 2020-02-04 23:35  vvf  阅读(84)  评论(0编辑  收藏  举报