0
우리는 Autofac을 사용하는 ASP.NET 응용 프로그램을 가지고 있습니다. 다음 오류가 온다 최대 :Autofac 오류를 제거하는 방법은 무엇입니까?
None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'ConcertRu.ApplicationsCore.Services.SessionWebAppService' can be invoked with the available services and parameters:
Cannot resolve parameter 'System.Web.HttpContext httpContext' of constructor 'Void .ctor(System.Web.HttpContext)'.
Cannot resolve parameter 'System.Web.HttpContextBase httpContext' of constructor 'Void .ctor(System.Web.HttpContextBase)'.
Cannot resolve parameter 'ConcertRu.Infrastructure.Contracts.IConcertHttpContext httpContext' of constructor 'Void .ctor(ConcertRu.Model.Contracts.IConcertDb, ConcertRu.Infrastructure.Contracts.IConcertHttpContext)'.
Global.asax.cs :
// Create the container builder.
var builder = new ContainerBuilder();
// Register the Web API controllers.
builder.RegisterControllers(Assembly.GetExecutingAssembly());
// Register other dependencies.
var services = typeof(AccessTokenService).Assembly;
builder.Register(c => ConcertDb.Current).As<IConcertDb>().SingleInstance();
builder.RegisterAssemblyTypes(services)
.Where(t => t.Name.EndsWith("Service")).AsImplementedInterfaces()
.SingleInstance();
// Build the container.
var container = builder.Build();
// Create the depenedency resolver.
var resolver = new AutofacDependencyResolver(container);
// Configure Web API with the dependency resolver.
DependencyResolver.SetResolver(resolver);
SessionWebAppService 클래스 :
public class SessionWebAppService : WebAppServiceBase, ISessionWebAppService
{
public SessionWebAppService(HttpContext httpContext)
: this(new ConcertDb(), new WebFormContext(httpContext))
{
}
public SessionWebAppService(HttpContextBase httpContext)
: this(new ConcertDb(), new MvcContext(httpContext))
{
}
public SessionWebAppService(IConcertDb concertDb, IConcertHttpContext httpContext)
: base(concertDb, httpContext)
{
}
...
}
WebAppServiceBase 클래스 :
public abstract class WebAppServiceBase : ModelServiceBase
{
private readonly IConcertHttpContext _httpContext;
protected WebAppServiceBase(IConcertDb concertDb, IConcertHttpContext httpContext) : base(concertDb)
{
_httpContext = httpContext;
}
...
}
이미 이러한 구성 요소를 등록하려고 시도했지만 새로운 오류가 발생합니다. – tesicg
내 질문은 - 무엇부터 시작해야할까요? – tesicg
[토론 포럼] (https://groups.google.com/forum/#!topic/autofac/WBJIRY5QsB0)과 동일한 질문을했으며 같은 것을 말했어. 등록하지 않았다면 묻는다면, 당신은 그것을 등록해야합니다. 그 후에 새로운 오류가 발생하면 그 오류는 무엇입니까? 하나의 등록 이상을 놓칠 수 있습니다. –