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


Type: System.ServiceModel.ServiceHostBase

The ServiceHostBase that hosts the service.

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

.NET Framework
Available since 3.0
Return to top