Giter VIP home page Giter VIP logo

Comments (2)

tillig avatar tillig commented on July 25, 2024

It looks like there's a problem with the repo, in that there's not enough code here to actually see all the workings.

I see this (trimming the comments)

IContainer container = builder.Build();
GlobalConfiguration.Configuration.DependencyResolver = new AutofacWebApiDependencyResolver(ContainerProvider.ApplicationContainer);

...but I don't see where ContainerProvider.ApplicationContainer is being set so there's something being trimmed out or over-simplified.

Is this a typo?

Can you provide more info, like whether you're using OWIN?

It seems you're also using Autofac.Web which is for web forms but there's no mention of this being a combination web forms + Web API app. If it's combo, you probably need to use the same container and not try to keep two separate containers based on the stack (web forms vs Web API).

from autofac.webapi.

jws305 avatar jws305 commented on July 25, 2024

Apologies, I found the issue somewhere else. I did leave a lot of the setup code from the example above.

My issue was that I was calling an async function from a synchronous context during the initialization of services using var res = GetAsync().Result;. This worked fine when I resolved the singleton service eagerly but failed when in the context of an http request.

from autofac.webapi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.