none
IoC usage in WCF web service RRS feed

  • Question

  • Hi,

    I have a WCF web service with a couple of methods that needs classes that are best built using IoC (autofac). My question is, where do I place the IoC container build. It is important that I can trust the container disposal. To me, I have these options:

    1. Create the container in each method. This would ensure that the container is disposed, but on the other hand building the (same) container for each method call could prove to be quite time-consuming. Also I dont like to have resolve from different places.

    2. Create the container and place it in a global static variable. But again I dont like to have resolve from different places. Also with this solution I can't control the disposal can I?

    Other options? What are the best practice usage when using IoC in web service methods?

    Thanks.

    Werner

    Thursday, October 9, 2014 6:23 PM

Answers