I am reviewing a project that has used Microsoft Patterns and Practices Unity Container.
There is a single container with 40 registered types, an instance of the container is created for every web service call.
I am wondering:
The web services are hosted in IIS.
Unity caches all sorts of stuff under the hood the first time a resolve is done. This significantly improves performance on later resolve calls. If you create a new container on every request, you're throwing out those caches.
Keep the container around between requests.
Please create the container and register all types during Application_Start. We've done this for around 200 + types in a large project (wcf and asp.net mvc) and have had no issues.
Thanks
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With