MVC 2预览1 - 控制器中带参数的方法无法加载

时间:2022-09-13 04:01:59

Plenty of pages load since upgrading my site from MVC 1.0 but if I go to a page that uses a querystring then I get this error:

自从MVC 1.0升级我的站点以来,加载了大量页面但是如果我转到使用查询字符串的页面,那么我会收到此错误:

[EntryPointNotFoundException: Entry point was not found.]
System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ControllerContext controllerContext, ParameterDescriptor parameterDescriptor) +219
System.Web.Mvc.ControllerActionInvoker.GetParameterValues(ControllerContext controllerContext, ActionDescriptor actionDescriptor) +109
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +399
System.Web.Mvc.Controller.ExecuteCore() +126
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +27
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +7
System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase httpContext) +151
System.Web.Mvc.MvcHandler.ProcessRequest(HttpContext httpContext) +57
System.Web.Mvc.MvcHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext httpContext) +7
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75

Edit

编辑

I thought this was related to structuremap as MVC 2 broke the model so I changed the DefaultControllerFactory but I have been able to pull data out of the db so structuremap isn't the issue?

我认为这与结构图相关,因为MVC 2破坏了模型,所以我更改了DefaultControllerFactory,但我已经能够从数据库中提取数据,因此结构图不是问题吗?

protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
    {
        try
        {                
            return ObjectFactory.GetInstance(controllerType) as Controller;

        }
        catch (StructureMapException)
        {
            System.Diagnostics.Debug.WriteLine(ObjectFactory.WhatDoIHave());
            throw;
        }
    }

1 个解决方案

#1


2  

Have you added assembly-binding to your project? I have nearly the same error and it solves problem for me. From release notes:

您是否已将装配绑定添加到项目中?我有几乎相同的错误,它解决了我的问题。从发行说明:

4.  If the project references any third-party libraries that are compiled against ASP.NET MVC 1.0, add the following bindingRedirect element to the Web.config file in the application root under the configuaton section:
<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
      <assemblyIdentity name="System.Web.Mvc" 
          publicKeyToken="31bf3856ad364e35"/>
      <bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0"/>
    </dependentAssembly>
  </assemblyBinding>
</runtime>

#1


2  

Have you added assembly-binding to your project? I have nearly the same error and it solves problem for me. From release notes:

您是否已将装配绑定添加到项目中?我有几乎相同的错误,它解决了我的问题。从发行说明:

4.  If the project references any third-party libraries that are compiled against ASP.NET MVC 1.0, add the following bindingRedirect element to the Web.config file in the application root under the configuaton section:
<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
      <assemblyIdentity name="System.Web.Mvc" 
          publicKeyToken="31bf3856ad364e35"/>
      <bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0"/>
    </dependentAssembly>
  </assemblyBinding>
</runtime>