我已经安装了autoFac和autoFac.Mvc5,但RegisterControllers()方法不可用



这是IDE的屏幕截图我已经安装了autofac和autofac.mvc5这两个软件包,但RegisterControllers()方法不可用;使用AutoFac.Integeration.Mvc";命名空间不可访问并且显示错误。

这是我的代码

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using OdoFood.Data.Services;
using System.Reflection;
using Autofac;
using Autofac.Integration.Mvc;
namespace OdoFood.Web
{
public class ContainerConfig
{
internal static void RegisterContainer()
{
var builder = new ContainerBuilder();
builder.RegisterController(typeof(MvcApplication).Assembly);


}

}
}

您的代码。。。

var builder = new ContainerBuilder();
builder.RegisterController(typeof(MvcApplication).Assembly);

表示CCD_ 1(单数)而不是CCD_ 2(复数)。在其末尾添加一个s

我遇到了同样的问题,这些步骤解决了问题:

  1. 卸载所有Autofac库
  2. 安装Autofac
  3. 安装Autofac.Mvc5

最新更新