On many projects I have used Ninject as my go-to dependency injection framework; it’s open source, flexible,  has good support, and a lot of extensions; but…it’s slow! Daniel Palme did some excellent work comparing the performance of various DI containers; see his results. Here is one of his conclusions supported by data:

Ninject is definitely the slowest container.

With this information I investigated using  the Simple Injector  DI framework. So far, I have used it on ASP.NET Web Forms, MVC, Web API, and console type applications. It’s a great simple super-fast DI framework, and its open source. I recommend trying it out [nuget  package].

Simple Injector is an easy-to-use Dependency Injection (DI) library for .NET 4+ that supports Silverlight, Windows Phone, Windows 8 including Universal apps and Mono. Simple Injector is easily integrated with frameworks such as Web API, MVC,  WCF, ASP.NET Core and many others. It’s easy to implement the dependency injection pattern with loosely coupled components using Simple Injector.”

I have been using Simple Injector in my custom Umbraco projects. Here is how it gets wired-up in the OnApplicationStarted() method:

using SimpleInjector;
using SimpleInjector.Integration.Web.Mvc;
using Umbraco.Core;
using Umbraco.Web.Mvc;


public class UmbracoEventHandler : IApplicationEventHandler

        public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
            var appName = ConfigurationManager.AppSettings["ApplicationName"];
            var websiteUrl= ConfigurationManager.AppSettings["WebsiteUrl"];
            var connectionString = ConfigurationManager.ConnectionStrings["umbracoDbDSN"].ConnectionString;

            var memberRepoParms = new MembershipRepoParms
                ApplicationName = appName,
                WebsiteUrl = websiteUrl,
                ConnectionString = connectionString,
                ApplicationContext = applicationContext

            //Code for registering the repository class and DI
            // 1. Create a new Simple Injector container
            var container = new Container();

            // 2. Configure the container (register)
            container.Register<IMembershipRepository>(() => new MembershipRepository(memberRepoParms));
            container.Register<RenderMvcController>(() => new RenderMvcController());

            // 3. Verify your configuration -- optional

            // MVC Package - These two extension methods from integration package
            DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));

            // 4. Use the container examples -- this code go in your custom controllers.
            // var repository = container.GetInstance<IMembershipRepository>();
            // var repository = DependencyResolver.Current.GetService<IMembershipRepository>();