Question

I am new to Wcf and tried to create my first Wcf services. Added class(new assembly) which has unmanaged code and do file manipulation. Service behavior is set as follow

InstanceContextMode = InstanceContextMode.Single

ConcurrencyMode = ConcurrencyMode.Single

When service is accessed is single mode, the new file manipulation class is created. I noticed that if file manipulation class fail(memory leak or critical error) all new connections to host affected by previous connections.

Is it possible to create Wcf instances which are fully isolated between each other and fully destroyed after client connection is closed?

regards, Tomas

Was it helpful?

Solution

Yes, that's the preferred mode - it's called "per-call":

InstanceContextMode = InstanceContextMode.PerCall

ConcurrencyMode = ConcurrencyMode.Single

That way, each request coming into your WCF service will gets it own, separate, isolated instance of the service class, and that instance will handle the request and then be disposed.

That should give you maximum performance, and isolation of requests from one another.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top