Autofac and ServiceStack

I finally decided to put this integration to a NuGet package.

There are two versions now:

  • The first version (1.0.1) supports ServiceStack V3, which remains a free version
Install-Package Autofac.Extras.ServiceStack -Version 1.0.1
  • Version 2.0 supports ServiceStack version 4
Install-Package Autofac.Extras.ServiceStack

The repository is on GitHub

Autofac and ServiceStack - Managing Life Cycle [3]

In the [previous part](../autofac-and-servicestack-managing-life.html) I suggested storing current scope in a static property. This seems to break under higher load because the scope is shared across too many instances of the same service and after the first request it gets disposed, leaving all other requests with dependencies from the disposed scope in unknown state, i.e. closed database session. After some more digging I found a way that really works. [Read More]

Autofac and ServiceStack - Managing Life Cycle [2]

Warning: this is not working properly, check the latest version for better solution. Whilst the approach I used in the previous post is working fine for ASP.NET based ServiceStack solutions, it does not fit for the self-hosted approach since the request handling is done differently there. To solve this issue, I tried to find ServiceStack native request/response hooks and the first thing I tried was a custom service runner with overrides for OnBeforeExecute and OnAfterExecute as described here. [Read More]

Autofac and ServiceStack - Managing Life Cycle

If you ever used Autofac with MVC or WebAPI, you know that integration modules provide you an ability to register your dependencies with life time scope that matches the HTTP request life cycle. However, when you are using ServiceStack, life becomes a bit more complicated. ServiceStack natively uses Funq and supports per-request life cycle with this container. You can provide an adapter for your own container but then the life cycle control is in your hands, ServiceStack will do nothing to help you there. [Read More]