I’m using WCF Services for a project I’m doing, where the Service will query an SQLite Database and return the desired information (Objects)
The problem I’m having is with Constructors and WCF. Is there a way around having the Service constructor called every single time a client connects to the service?
I’ve included some testing code so you can see what I’m talking about.
Testing code (Simulation of 20 clients connecting to WCF Service)
http://pastebin.com/sP30zm1w
WCF Service Library
http://pastebin.com/MvPLYKax
What you are seeing is called “Per-Call” instancing. This means that the service class is created once per call to the service.
The behavior is controlled by the
InstanceContextModeconfig setting in WCF. YOu can change this to:Here is an MSDN article that explains some of it.
And another article.