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

StackOverflow https://stackoverflow.com/questions/21376261

  •  03-10-2022
  •  | 
  •  

문제

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
도움이 되었습니까?

해결책

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.

다른 팁

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

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.

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>

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top