我刚刚更新到最新的 ASP.NET MVC,我得到:
Method not found: 'System.Web.Routing.RouteValueDictionary
System.Web.WebPages.TypeHelper.ObjectToDictionaryUncached(System.Object)'.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.MissingMethodException: Method not
found: 'System.Web.Routing.RouteValueDictionary
System.Web.WebPages.TypeHelper.ObjectToDictionaryUncached(System.Object)'.
Source Error:
Line 12: public static void RegisterRoutes(RouteCollection routes)
Line 13: {
Line 14: routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
Line 15:
Line 16: //routes.MapRoute(
Source File: C:\ProjectX\App_Start\RouteConfig.cs Line: 14
Stack Trace:
[MissingMethodException: Method not found: 'System.Web.Routing.RouteValueDictionary
System.Web.WebPages.TypeHelper.ObjectToDictionaryUncached(System.Object)'.]
System.Web.Mvc.RouteCollectionExtensions.CreateRouteValueDictionaryUncached(Object values) +0
System.Web.Mvc.RouteCollectionExtensions.IgnoreRoute(RouteCollection routes, String url,
Object constraints) +94
System.Web.Mvc.RouteCollectionExtensions.IgnoreRoute(RouteCollection routes, String url) +7
COP.RouteConfig.RegisterRoutes(RouteCollection routes) in C:\ProjectX\App_Start\RouteConfig.cs:14
COP.MvcApplication.Application_Start() in C:\ProjectX\Global.asax.cs:27
[HttpException (0x80004005): Method not found: 'System.Web.Routing.RouteValueDictionary
System.Web.WebPages.TypeHelper.ObjectToDictionaryUncached(System.Object)'.]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context,
HttpApplication app) +9935033
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext
context, MethodInfo[] handlers) +118
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers,
IntPtr appContext, HttpContext context) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext,
HttpContext context) +336
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296
[HttpException (0x80004005): Method not found: 'System.Web.Routing.RouteValueDictionary
System.Web.WebPages.TypeHelper.ObjectToDictionaryUncached(System.Object)'.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9913572
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr,
HttpContext context) +254
我什至第二次通过了文档中的 DLL 列表作为检查列表,以确保我没有遗漏任何内容。但是,我显然遗漏了一些东西。
请您参考如下方法:
尝试将您的 Web.config 和 packages.config 恢复到以前的可用版本并降级 NuGet 包... 这可能是因为你的 MVC 已经升级,而一些相关的 DLL 仍然是旧的和不兼容的版本......
我遇到了类似的问题,我通过修改项目文件夹下的 Web.config 解决了这个问题,如下所示:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930"
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.1.0.0" newVersion="5.1.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
