Windows apps
Collapse the table of content
Expand the table of content
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
Available since 3.0
Return to top
Show:
© 2017 Microsoft