I'm configuring validation application block from Enterprise Library 5 to use validation rules from the web.config file over a WCF call.
The problem is as new calls to the WCF service occur, validation application block is spending a considerable amount of time reading the validation configuration before validating. So my first call to the service which checks if a certain username is available to use (this method also does validation on the username before checking database) take a long time, but every call after that is pretty much instant. Then when I press F5 in my browser and try again, it takes a very long time to setup (read the config validation rules) again.
I read in the Developers guide to Ent Lib 5 that I should maintain a reference to the default Unity container that is setup and use this container to resolve the references. It suggests that I should use a custom extension to the InstanceContext to achieve this but does not give any examples.
How do I do this? Does anyone have examples? I am thinking holding onto a reference to the Unity container could solve the initial speed issues of hitting the service for the first time.
I should mention that I have the following on my service:
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, InstanceContextMode = InstanceContextMode.Single)]