WebApi / AutoFac and an iDependencyResolver error

zExz

New Member
I have got a DDD-layered application, so it contains both an Asp.Net MVC 4 project and an WebApi project (2 projects in the presentation layer).Adding Autofac with Asp.Net MVC 4 = okAdding Autofac with Asp.Net WebApi = not okThis is my global.asax.cs from my asp.net web api\[code\]var configuration = GlobalConfiguration.Configuration;var builder = new ContainerBuilder();// Configure the container with the integration implementations.// builder.ConfigureWebApi(configuration);builder.RegisterWebApiFilterProvider(configuration);// Register API controllers using assembly scanning.builder.RegisterApiControllers(Assembly.GetExecutingAssembly());builder.RegisterType(typeof(UnitOfWork)).As(typeof(IUnitOfWork)).InstancePerLifetimeScope() .OnRelease(x => { ((IUnitOfWork)x).Commit(); });builder.RegisterType(typeof(DatabaseFactory)).As(typeof(IDatabaseFactory)).InstancePerLifetimeScope().AsImplementedInterfaces();builder.RegisterAssemblyTypes(typeof(UserRepository).Assembly).Where(t => t.Name.EndsWith("Repository")).AsImplementedInterfaces();builder.RegisterAssemblyTypes(typeof(SecurityService).Assembly).Where(t => t.Name.EndsWith("Service")).AsImplementedInterfaces();var container = builder.Build();// Set the dependency resolver implementation.var resolver = new AutofacWebApiDependencyResolver(container);configuration.ServiceResolver.SetResolver(resolver);\[/code\]The error i'm seeing is : Could not load type 'System.Web.Http.Dependencies.IDependencyResolver' from assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.Tried rewriting the part of code for 3 times, but it just doesn't seem to work.Already found some links to some blogs, but mostly they contain a reference to \[code\]builder.ConfigureWebApi(configuration);\[/code\] and that doesn't exist in the newer version.Any thoughts on how I could solve this?
 
Back
Top