WCF and container lifetime

I'm sure this is obvious but I haven't been able to find a very specific clean answer to the lifetime of a container in a IIS 7.5 hosted WCF service.

If the container lives in my service code, it would be created on every request unless InstanceContextMode is set to single? (I know bad idea)

If I configure WCF using ServiceHostFactory and IInstanceProvider to use a container to resolve the service object on every call how would the InstanceContextMode work? Wouldn't it depend on the lifetime policy used by the container?

If its a singleton created in the factory is that sufficient such that the container won't reinitialize on every call?

Thanks

Answers


You should host the container in a custom ServiceHostFactory since there's only a single instance of the ServiceHostFactory for a given WCF service.

This ensures that the container itself is a single instance, thus enabling it to effectively manage lifetime of all components.


Need Your Help

Converting “2013-09-06 10:30pm GMT+1” string to PHP DateTIme object in UTC

php string parsing datetime utc

I am trying to convert the following string: 2013-09-06 10:30pm GMT+1 to a PHP DateTime object. In the process, it also has to convert it to UTC. I tried the code below but obviously that was incor...

Android: get response from the servlet

android servlets login

I have a login servlet that looks like this:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.