Mvc 5.1 MissingMethodException System.Web.WebPages.TypeHelper.ObjectToDictionaryUncached

好久不见. 提交于 2019-12-17 19:47:05

问题


I'm update my MVC5 project to MVC5.1 and now have exception on route dictionary:

routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

stack trace:

{"Method not found: 'System.Web.Routing.RouteValueDictionary System.Web.WebPages.TypeHelper.ObjectToDictionaryUncached(System.Object)'."}

at System.Web.Mvc.RouteCollectionExtensions.CreateRouteValueDictionaryUncached(Object values)
at System.Web.Mvc.RouteCollectionExtensions.IgnoreRoute(RouteCollection routes, String url, Object constraints)
at System.Web.Mvc.RouteCollectionExtensions.IgnoreRoute(RouteCollection routes, String url)
at WebApplication1.RouteConfig.RegisterRoutes(RouteCollection routes) in c:\Users\aivanov\Documents\Visual Studio 2013\Projects\WebApplication1\WebApplication1\App_Start\RouteConfig.cs:line 14
at WebApplication1.MvcApplication.Application_Start() in c:\Users\aivanov\Documents\Visual Studio 2013\Projects\WebApplication1\WebApplication1\Global.asax.cs:line 17

回答1:


In the References i found that System.Web.WebPages.dll version 3.0.11001.0 shows this type of error, but when i replace it with System.Web.WebPages.dll version 3.0.20129.0 it works. So Simply you should delete the old one from refrences and download the other version and than clean solution, rebuild and it will work.




回答2:


In my case helped deleting files in temporary folder "C:\Users{yourprofilename}\AppData\Local\Temp\Temporary ASP.NET Files\"




回答3:


Please make sure you have a reference to : using System.Web.Http; (c)
or Imports System.Web.Http (vb)

At the top of your RouteConfig File in App_Start directory.

Other than that, although the title is a bit off topic, you might find what your looking for at this link on MS: http://www.asp.net/mvc/tutorials/older-versions/controllers-and-routing/asp-net-mvc-routing-overview-cs - Hopefully this will get you going in the right direction! If you have other details, please let me know and I would be more than happy to continue to try and help!

Hope all is well.




回答4:


In addition to the step suggested by @Leonardo, I also had to add the following to my Web.config:

<compilation debug="true" targetFramework="4.5.1">
    <assemblies>
        <add assembly="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"></add>
    </assemblies>
</compilation>



回答5:


I reinstalled the nuget packages for Microsoft Asp.Net MVC and it worked for me. I am not sure but I think this problem occurs after upgrading MVC version. So reinstalling nuget package worked.



来源:https://stackoverflow.com/questions/21376261/mvc-5-1-missingmethodexception-system-web-webpages-typehelper-objecttodictionary

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!