public static void SetDependencyResolver() { var builder = new ContainerBuilder(); var assembly = typeof(DependencyResolverConfig).Assembly; builder.RegisterControllers(assembly); builder.RegisterFilterProvider(); builder.RegisterAssemblyTypes(assembly) .Where(t => t.Namespace.EndsWith("GUT.Core.Repositories") && t.IsInterface == false) .AsImplementedInterfaces() .InstancePerHttpRequest(); builder.RegisterAssemblyTypes(assembly) .Where(t => t.IsAssignableTo <ISpecification>()) .AsSelf() .InstancePerHttpRequest(); builder.Register(i => SessionPerRequestModule.Session).As <ISession>(); builder.RegisterGeneric(typeof(Repositorio <>)).As(typeof(IRepositorio <>)).InstancePerHttpRequest(); builder.Register(r => ISecurityContext.GetContext()).As <ISecurityContext>(); builder.Register(r => ISecurityContext.GetContext().UserManager).As <IUserManager>(); builder.Register(r => ISecurityContext.GetContext().RoleManager).As <IRoleManager>(); builder.Register(r => ISecurityContext.GetContext().UserRoleAuthorizationManager).As <IUserRoleAuthorizationManager>(); builder.Register(r => ISecurityContext.GetContext().UserInactivationManager).As <IUserInactivationManager>(); DependencyResolver.SetResolver(new AutofacDependencyResolver(builder.Build())); }