wcf控制台发布
电脑版发表于:2021/4/25 17:17
代码如下:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.ServiceModel; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { using (ServiceHost serviceHost = new ServiceHost(typeof(Service1))) { //监听事件 serviceHost.Opening += serviceHost_Opening; serviceHost.Opened += serviceHost_Opened; //开启接口 serviceHost.Open(); Console.ReadLine(); } } static void serviceHost_Opened(object sender, EventArgs e) { Console.WriteLine("接口发布成功"); } static void serviceHost_Opening(object sender, EventArgs e) { Console.WriteLine("接口发布中..."); } } }