InstanceContext.Host 属性

定义

获取服务实例的主机。

public:
 property System::ServiceModel::ServiceHostBase ^ Host { System::ServiceModel::ServiceHostBase ^ get(); };
public System.ServiceModel.ServiceHostBase Host { get; }
member this.Host : System.ServiceModel.ServiceHostBase
Public ReadOnly Property Host As ServiceHostBase

属性值

承载服务实例的 ServiceHostBase

例外

与此上下文关联的服务实例已关闭,但是没有中止。

与此上下文关联的服务实例处于错误状态。

示例

下面的代码演示如何访问 Host 属性:

Uri baseAddress = new Uri("http://localhost:8000/ServiceModelSamples/service");
CalculatorService service = new CalculatorService();
ServiceHost serviceHost = new ServiceHost(service, baseAddress);
InstanceContext instanceContext = new InstanceContext(serviceHost, service);

ServiceHost host = (ServiceHost) instanceContext.Host;

适用于