How do I use AutofacWebTypesModule to Resolve HttpServerUtilityBase

Posted by Scott Weinstein on Stack Overflow See other posts from Stack Overflow or by Scott Weinstein
Published on 2011-02-16T23:22:05Z Indexed on 2011/02/16 23:25 UTC
Read the original article Hit count: 987

Filed under:
|

I have the following registrations

    builder.RegisterModule(new AutofacWebTypesModule());
    builder.Register<MyType>(ctx =>
    {
        var server = ctx.Resolve<HttpServerUtilityBase>();
        ...
    });

When I try to resolve MyType via a constructor on an Controller, I get the following exception. What am I doing wrong?

Autofac.Core.DependencyResolutionException was unhandled by user code
Message=No scope matching the expression 'value(Autofac.Builder.RegistrationBuilder`3+<>c__DisplayClass0[System.Web.HttpServerUtilityBase,Autofac.Builder.SimpleActivatorData,Autofac.Builder.SingleRegistrationStyle]).lifetimeScopeTag.Equals(scope.Tag)' is visible from the scope in which the instance was requested.

© Stack Overflow or respective owner

Related posts about asp.net-mvc-3

Related posts about autofac