Home > Development > WCF Instance Context

WCF Instance Context


The Instance Context in WCF represents the running instance of a service along with its state. Im reading a WCF book at the moment and it mentions that the context holds the service instance. After some playing around and creating a test solution i created two services 1 that was a session and a per call. If you put the the following code in a method marked with operationcontract and break point on it you get some interesting results.

var hcode = OperationContext.Current.InstanceContext.GetServiceInstance().GetHashCode();

If it is a session method the hash code will be the same every-time and per call will be different. Basically I think this object holds the service instance and acts as a broker for instancing. It also provides some useful context information on the service instance environment.

See Dan Rigsby’s Great Post here.

Blair…

Advertisements
Categories: Development Tags: , ,
  1. No comments yet.
  1. January 2, 2011 at 11:22 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: