Edit

Share via


InstanceContext.Host Property

Definition

Gets the host for the service instance.

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

Property Value

The ServiceHostBase that hosts the service instance.

Exceptions

The service instance associated with this context is closed, but was not aborted.

The service instance associated with this context is in a faulted state.

Examples

The following code shows how to access the Host property:

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;

Applies to