Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8038617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:17:30+00:00 2026-06-05T03:17:30+00:00

var resolver = new AutofacWebApiDependencyResolver(container); configuration.ServiceResolver.SetResolver(resolver); after updating to ASP.NET MVC4 (RC) I get

  • 0
var resolver = new AutofacWebApiDependencyResolver(container);
configuration.ServiceResolver.SetResolver(resolver);

after updating to ASP.NET MVC4 (RC) I get the following error:

‘System.Web.Http.HttpConfiguration’ does not contain a definition for
‘ServiceResolver’ and no extension method ‘ServiceResolver’ accepting
a first argument of type ‘System.Web.Http.HttpConfiguration’ could be
found (are you missing a using directive or an assembly reference?)

I realize after reading this (http://www.asp.net/web-api/overview/extensibility/using-the-web-api-dependency-resolver) that these interfaces have changed, but I am not sure how to apply this change to how I use Autofac.

Do i need to wait for a new release from Autofac or is there another way I can get past this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T03:17:31+00:00Added an answer on June 5, 2026 at 3:17 am

    Edit:
    As James Bradt mentions in his post below, the Autofac package has now been updated to fix this issue, so anyone coming across this thread in the future should probably try the new package first 🙂

    Basically, with the new package you just need to do this in your global.asax.cs:

    GlobalConfiguration.Configuration.DependencyResolver = new Autofac.Integration.WebApi.AutofacWebApiDependencyResolver(container);
    

    /Edit

    I just came across the same issue – I was able to resolve it in my situation by creating a simple IDependencyResolver implementation that wraps the existing AutofacDependencyResolver.

    As the class name suggests, I’m treating this as a temporary resolution – the BeginScope and Dispose methods will need some work and are obviously not suitable for a production environment but this allows me to continue development until a proper solution emerges.

    So, with those caveats, the IDependencyResolver implementation looks like this:

    public class TemporaryDependencyResolver : IDependencyResolver
    {
        private readonly AutofacDependencyResolver _autofacDependencyResolver;
    
        public TemporaryDependencyResolver(AutofacDependencyResolver autofacDependencyResolver)
        {
            _autofacDependencyResolver = autofacDependencyResolver;
        }
    
        public void Dispose()
        {
        }
    
        public object GetService(Type serviceType)
        {
            return _autofacDependencyResolver.GetService(serviceType);
        }
    
        public IEnumerable<object> GetServices(Type serviceType)
        {
            return _autofacDependencyResolver.GetServices(serviceType);
        }
    
        public IDependencyScope BeginScope()
        {
            return this;
        }
    }
    

    and I set it like this in Global.asax.cs:

    var container = builder.Build();
    var resolver = new AutofacDependencyResolver(container);
    GlobalConfiguration.Configuration.DependencyResolver = new TemporaryDependencyResolver(resolver);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Microsoft Unity i register the following type: container.RegisterType(typeof(IRepository<>), typeof(NHibernateRepository<>)); In ASP.NET MVC 2
I've found very strange C# compiler behavior for following code: var p1 = new
In the following example using (var context = new MyEntities() { // Delete old
I have code (simplified) Configuration: _container.AddComponent<IRepository<Project>, FakeProjectRepository>(); var instance = new List<Project>(); _container.Kernel.AddComponentInstance<IList<Project>>(instance); Class:
var htm = $.ajax({ type: GET, url: ./viewforms, async: false }).responseText; var myObject =
I noticed that when I installed StructureMap from NuGet into my ASP.NET MVC3 project,
What is the NInject equivalent of the following code that uses Autofac: var builder
I have created an ASP.Net MVC Web Application and used NuGet to install Ninject
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(content); var nodes = doc.DocumentNode.SelectNodes(//div[@class=\noprint res\]/div); if (nodes !=
Im new to NHibernate, the configuration aspect of it has always seemed overly onerous

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.