从过去的 6 个小时开始,我一直在努力解决这个问题,但仍然无法解决这个问题。当我在共享主机的服务器上部署一个 Asp.Net Mvc 4 项目时,我遇到了这个异常。我得到了这个问题。
我用谷歌搜索发现这可能是与 System.Web.Mvc 和 System.Web.WebPages 的版本差异有关的问题。我验证了所有 dll 的版本号,尝试使用 nuget 重新安装,但仍然收到相同的消息。
认为这可能只是与我的项目有关的问题,我创建了一个新的 Asp.Net Mvc 4 Internet 应用程序并将其部署在服务器上,繁荣......得到了同样的信息。
我花了几个小时卸载所有旧版本的 Asp.Mvc,修复 Visual Studio 2010,使用 Web Platform Installer 再次安装 Mvc 4,但没有任何帮助,仍然收到相同的消息。
有人可以帮忙吗,我只是卡住了。
这是错误消息
Could not load type 'System.Web.WebPages.DisplayModes' from assembly 'System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
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.TypeLoadException: Could not load type 'System.Web.WebPages.DisplayModes' from assembly 'System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[TypeLoadException: Could not load type 'System.Web.WebPages.DisplayModes' from assembly 'System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.]
System.Web.Mvc.VirtualPathProviderViewEngine.GetPath(ControllerContext controllerContext, String[] locations, String[] areaLocations, String locationsPropertyName, String name, String controllerName, String cacheKeyPrefix, Boolean useCache, String[]& searchedLocations) +0
System.Web.Mvc.VirtualPathProviderViewEngine.FindView(ControllerContext controllerContext, String viewName, String masterName, Boolean useCache) +198
System.Web.Mvc.<>c__DisplayClassc.<FindView>b__a(IViewEngine e) +43
System.Web.Mvc.ViewEngineCollection.Find(Func`2 lookup, Boolean trackSearchedPaths) +177
System.Web.Mvc.ViewEngineCollection.Find(Func`2 cacheLocator, Func`2 locator) +23
System.Web.Mvc.ViewResult.FindView(ControllerContext context) +144
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +151
System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +33
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +846308
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +265
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +846608
System.Web.Mvc.Controller.ExecuteCore() +159
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +335
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +62
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +20
System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +54
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +469
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +375
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272
这是我用谷歌搜索并找到解决问题的链接:
http://tkntips.blogspot.in/2012/05/could-not-load-type-systemwebwebpagesdi.html
解决方案不是那么清楚。没有为我工作。