我现在一直在研究一些WebMVC5应用程序。突然间它不会再开始了。问题与区域有关。我的项目中有一个区域一直有效。现在,当我开始调试时,我得到一个ArgumentException。
异常发生在:
AreaRegistration.RegisterAllAreas();
在Global.asax.cs中
异常消息是:
值不能为null或为空。参数名称:areaName
异常不在我的代码中,而是在System.Web.Mvc库中。当我深入研究它时,它在AreaRegistration类的CTOR中:
System.Web.Mvc.AreaRegistration.RegisterAllAreas(RouteCollection)上的System.Web.Mvc.AreaRegistration.CreateContextAndRegister(RouteCollection routes,Object state)中的System.Web.Mvc.AreaRegistrationContext..ctor(String areaName,RouteCollection routes,Object state)在System.Web.Mvc.AreaRegistration.RegisterAllAreas(对象状态)处的System.Web.Mvc.AreaRegistration.RegisterAllAreas()处于X.Web.Application.WebApiApplication.Application_Start()处的路由,IBuildManager构建管理器,对象状态)
我猜我的问题是,下一步是什么?我试过打扫这个项目。我尝试将nuget包重新安装到项目中。
我们有完全相同的错误/问题。我们使用Microsofts Fake组件来测试我们的MVC控制器。不知何故,一些假组件在Web项目和单元测试项目中被引用。从MVC项目中删除引用的假装配后,一切正常 - 再次!
也许这有帮助!
几天前我遇到了同样的错误,我确实通过以下方式解决了这个错误: