共用方式為


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;

適用於