WCF Web/ServiceHost - Singletons and initialisation

Posted by Kyle on Stack Overflow See other posts from Stack Overflow or by Kyle
Published on 2010-05-21T01:31:47Z Indexed on 2010/05/21 1:40 UTC
Read the original article Hit count: 259

Filed under:
|
|
|
|

I have some Service class which is defined as InstanceContextMode.Single, and is well known in the hosting application. (The host creates an instance, and passes that to the WebServiceHost)

Hosting app:

WebServiceHost host = null;
SomeService serviceInstance = new SomeService("text", "more text");
host = new WebServiceHost(serviceInstance, baseUri);
Problem:
When I go to use the variables initialised when the service is created (ie, when a call is made to the service), they are either null or empty...

Am I wrong in assuming that as the instance being initialised in the hosting application is used for each request to the WebServiceHost?

Any pointers here would be great.

© Stack Overflow or respective owner

Related posts about servicehost

Related posts about wcf