InstanceContext.ReleaseServiceInstance Method

Definition

Releases the service instance.

C#
public void ReleaseServiceInstance ();

Exceptions

The service instance is in a created or opening state and cannot be used.

The service instance has been aborted.

The service instance is closing or has been closed already and cannot be modified.

The service instance is faulted and cannot be modified in these states.

Examples

C#
Uri baseAddress = new Uri("http://localhost:8000/ServiceModelSamples/service");

// Create a ServiceHost for the CalculatorService type and provide the base address.
using (ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress))
{
    serviceHost.Open();
    OperationContext operationContext = OperationContext.Current;
    InstanceContext instanceContext = operationContext.InstanceContext;
    instanceContext.ReleaseServiceInstance();
}

Applies to

제품 버전
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1