Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Autofac - InstancePerHttpRequest ambiguous call

I need to reference both Autofac.Integration.Mvc and Autofac.Integration.Web dll's in my MVC3 project and am encountering the following naming conflict with the InstancePerHttpRequest() method:

This call is ambiguous between Autofac.Integration.Mvc and Autofac.Integration.Web

I need both dll's to be referenced as my project is MVC3 but elements are integrating SQL SSRS reports which demand the use of ASPX pages because of the ReportViewer control is required. I need to resolve my my service classes to call functionality from my APSX code behind. Any ideas how I can resolve this naming conflict please or is this totally incompatible?

like image 822
Brian Mantay Avatar asked May 03 '26 06:05

Brian Mantay


1 Answers

InstancePerHttpRequest is an extension method and as such it is declared as a normal static method in the classes Autofac.Integration.Web.RegistrationExtensions and Autofac.Integration.Mvc.RegistrationExtensions.

The solution is to call the method explicitly:

Autofac.Integration.Web.RegistrationExtensions
         .InstancePerHttpRequest(yourBuilder.Register(c => ...)

Or to include just one of these two namespaces (its not the reference that makes the ambiguity):

using Autofac.Integration.Web;
using Autofac.Integration.Mvc;
like image 153
Jan Avatar answered May 05 '26 09:05

Jan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!