在控制台宿主程序中,为什么不能同时实例化两个ServiceHost?

代码如下: 

using (ServiceHost 
                DuplexCommonHost = new ServiceHost(typeof(DuplexCommonService)), 
                OneWayCommonHost = new ServiceHost(typeof(OneWayCommonService)))
            {
                DuplexCommonHost.Opened += delegate { Console.Write("DuplexCommon service has been opened!"); };
                DuplexCommonHost.Open();

                OneWayCommonHost.Opened += delegate { Console.Write("OneWayCommon service has been opened!"); };
                OneWayCommonHost.Open();

                Console.Read();   
            }

结果客户端报一下错误:没有终结点在侦听可以接受消息的 http://localhost:8080/OneWayCommon

屏蔽红色部分代码,客户端正常运行。


侃侃尔雅
浏览 609回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP