Asp.net mvc 调试带有Ninject错误的MVC3源代码
我试图理解Html助手是如何在MVC3中构建的。所以我下载了MVC3源代码,并将其添加为同一解决方案中的另一个项目来调试它 我遵循这个步骤Asp.net mvc 调试带有Ninject错误的MVC3源代码,asp.net-mvc,asp.net-mvc-3,ninject,Asp.net Mvc,Asp.net Mvc 3,Ninject,我试图理解Html助手是如何在MVC3中构建的。所以我下载了MVC3源代码,并将其添加为同一解决方案中的另一个项目来调试它 我遵循这个步骤 已从我的Mvc应用程序中删除System.web.Mvc引用 添加了用于调试的System.web.Mvc源代码项目参考 在Web.config System.Web.Mvc中,Version=3.0.0.0,Culture=neutral,PublicKeyToken=31BF3856AD364E35到System.Web.Mvc 但是,我在我的MVC3应
MVC
3应用程序中添加了其他NInject
(NInject
,NInject.web.common
,WebActivator
,Microsoft.web.infrastructure
)引用,用于依赖注入
现在,我在System.Web.MVC
源代码中收到一个错误尝试创建“MVCApp.Controllers.HomeController”类型的控制器时出错。确保控制器具有无参数公共构造函数。
在下面的MVC
源代码中
public IController Create(RequestContext requestContext, Type controllerType)
{
try
{
return (IController)(_resolverThunk().GetService(controllerType)
?? Activator.CreateInstance(controllerType));
}
catch (Exception ex)
{
throw new InvalidOperationException(
String.Format(CultureInfo.CurrentCulture,
MvcResources.DefaultControllerFactory_ErrorCreatingController, controllerType),
ex);
}
}
正在检查依赖解析程序。当前属性显示
DependencyResolver。当前类型
“System.Web.Mvc.DependencyResolver”在这两个版本中都存在
'System.Web.Mvc.dll'和'System.Web.Mvc.dll'
为了用MVC3源代码调试我的MVC3App,还需要做什么?如何避免这个错误 看看这个解决方案: 将其添加到Web.config
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0" newVersion="4.0.0.0" />
<bindingRedirect oldVersion="2.0.0.0" newVersion="4.0.0.0" />
<!-- The following line was missing -->
<bindingRedirect oldVersion="3.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
它解决了这个问题:
正在检查DependencyResolver。当前属性为
DependencyResolver。当前类型
“System.Web.Mvc.DependencyResolver”在这两个版本中都存在
'System.Web.Mvc.dll'和'System.Web.Mvc.dll'
干杯。这方面运气好吗?我正在吃这个problem@vtortola,我找不到适合这个的。我放弃了用NInject调试源代码的计划:(感谢您提供了解决方案