TeachingNote

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("接口发布中...");
        }
    }
}


关于TNBLOG
TNBLOG,技术分享。技术交流:群号677373950
ICP备案 :渝ICP备18016597号-1
App store Android
精彩评论
{{item.replyName}}
{{item.content}}
{{item.time}}
{{subpj.replyName}}
@{{subpj.beReplyName}}{{subpj.content}}
{{subpj.time}}
猜你喜欢