ChannelDispatcher.Detach(ServiceHostBase) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将服务主机与通道调度程序分离。
protected:
override void Detach(System::ServiceModel::ServiceHostBase ^ host);
protected override void Detach (System.ServiceModel.ServiceHostBase host);
override this.Detach : System.ServiceModel.ServiceHostBase -> unit
Protected Overrides Sub Detach (host As ServiceHostBase)
参数
- host
- ServiceHostBase
该服务的 ServiceHostBase。
例外
host
为 null
。
通信对象处于 Faulted 状态。
示例
Uri baseAddress = new Uri("http://localhost:8001/Simple");
ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress);
serviceHost.AddServiceEndpoint(
typeof(ICalculator),
new WSHttpBinding(),
"CalculatorServiceObject");
serviceHost.Open();
IChannelListener icl = serviceHost.ChannelDispatchers[0].Listener;
ChannelDispatcher dispatcher = new ChannelDispatcher(icl);
dispatcher.CloseInput();
Dim baseAddress As New Uri("http://localhost:8001/Simple")
Dim serviceHost As New ServiceHost(GetType(CalculatorService), baseAddress)
serviceHost.AddServiceEndpoint(GetType(ICalculator), New WSHttpBinding(), "CalculatorServiceObject")
serviceHost.Open()
Dim icl As IChannelListener = serviceHost.ChannelDispatchers(0).Listener
Dim dispatcher As New ChannelDispatcher(icl)
dispatcher.CloseInput()
注解
只有当 ServiceHostBase 的实例处于 ChannelDispatcher 状态时才可以分离 Created,因为该状态是唯一一个可变且不被释放的状态。
将与通道调度程序关联的 ServiceHostBase 设置为 null
。