Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

InstanceContext Constructor (ServiceHostBase, Object)

Initializes a new instance of the InstanceContext class for a specified object that implements the service instance and is hosted by a specified host.

Namespace:  System.ServiceModel
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

public InstanceContext(
	ServiceHostBase host,
	Object implementation
)

Parameters

host
Type: System.ServiceModel.ServiceHostBase

The ServiceHostBase that hosts the service.

implementation
Type: System.Object

The object that implements the service instance.

The following code illustrates how to create an InstanceContext object by first creating the service object and ServiceHost object:

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);

string info = "";
info += "    " + "State: " + instanceContext.State.ToString() + "\n";
info += "    " + "ManualFlowControlLimit: " + instanceContext.ManualFlowControlLimit.ToString() + "\n";
info += "    " + "HashCode: " + instanceContext.GetHashCode().ToString() + "\n";
Console.WriteLine(info);

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft