gpt4 book ai didi

asp.net-mvc - 该模块要求 HttpApplication 实现 IContainerProviderAccessor

转载 作者:行者123 更新时间:2023-12-01 19:46:33 25 4
gpt4 key购买 nike

嗨我想在我的 asp.net mvc 应用程序中使用 Autofac,这是我在 global.asxc 文件中的代码:

 protected void Application_Start()
{
....

var builder = new ContainerBuilder();
builder.RegisterControllers(Assembly.GetExecutingAssembly());

IContainer container = builder.Build();

DependencyResolver.SetResolver(new AutofacDependencyResolver(container));

}

但是当我运行该项目时,我看到此错误:

该模块要求 HttpApplication(全局应用程序类)实现 IContainerProviderAccessor

出了什么问题?

最佳答案

我遇到了与OP相同的问题,但我的解决方案不同。

来自here :

Remove Old Items

  • Remove IContainerProviderAccessor interface from Global.asax. This implementation is no longer used by ASP.NET MVC integration.
  • Remove references to the AutofacControllerFactory. The new MVC integration uses the MVC DependencyResolver class for integration instead.
  • Remove ASP.NET Autofac HTTP module configurations. Previously there were some Autofac ContainerDisposal and PropertyInjection modules required in your web.config. These should be removed.

关于asp.net-mvc - 该模块要求 HttpApplication 实现 IContainerProviderAccessor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6013976/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com