【问题标题】:Issue with System.Web.WebPages after installing MVC4安装 MVC4 后 System.Web.WebPages 出现问题
【发布时间】:2012-08-16 04:40:06
【问题描述】:

我已经安装了 MVC4 和我现在拥有的 MVC3 应用程序给我带来了问题。我得到错误:

无法加载文件或程序集“System.Web.WebPages,Version=2.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35”或其依赖项之一。找到的程序集的清单定义与程序集引用不匹配

但是,我在我的代码中找不到任何对 WebPages v2 的引用,我想知道为什么会出现此错误。有人可以帮忙吗?

编辑:这是完整的堆栈跟踪:

[FileLoadException: 无法加载文件或程序集 'System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' 或其依赖项之一。找到的程序集的清单定义与程序集引用不匹配。 (来自 HRESULT 的异常:0x80131040)] C:\Users\M\Desktop\Development\ASP.NET 项目\ljMVC\ljMVC\ljMVC\Helpers\EditableHelpers 中的 ljMVC.Helpers.EditableHelpers.Editable(HtmlHelper 助手,字符串 htmlElement,字符串 cssId,字符串 defaultContent,对象 htmlAttributes)。 CS:90 ASP._Page_Areas_Gameplan_Views_MainGP_Index_cshtml.Execute() 在 e:\web\lovelyjubbl\htdocs\Areas\Gameplan\Views\MainGP\Index.cshtml:85 System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +208 System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +89 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +78 System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +199 System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +107 System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext 上下文)+291 System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13 System.Web.Mvc.c_DisplayClass1c.b_19() +23 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter 过滤器,ResultExecutingContext preContext,Func1 continuation) +264 System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +20 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList1 过滤器,ActionResult actionResult)+176 System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +329 System.Web.Mvc.Controller.ExecuteCore() +115 System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +94 System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10 System.Web.Mvc.c_DisplayClassb.b_5() +37 System.Web.Mvc.Async.c_DisplayClass1.b_0() +21 System.Web.Mvc.Async.c_DisplayClass81.<BeginSynchronous>b__7(IAsyncResult _) +12 System.Web.Mvc.Async.WrappedAsyncResult1.End() +55 System.Web.Mvc.c_DisplayClasse.b_d() +31 System.Web.Mvc.SecurityUtil.b_0(动作 f)+7 System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(动作动作)+23 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +59 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult 结果) +9 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8970061 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184

【问题讨论】:

  • 请发布完整的异常堆栈跟踪。包含calling assembly 的部分特别有趣,因为它会告诉您哪个程序集正在尝试加载此程序集。而且您一定对这个 ASP.NET MVC 3 应用程序做了一些事情。它是什么?仅安装 ASP.NET MVC 4 不会对现有应用程序产生任何影响。我相信你已经修改了一些东西。就像在这个 MVC 3 应用程序中安装/更新 NuGet 或其他东西一样。它只是不会自行破裂。我有无数的 MVC 3 应用程序,安装 MVC 4 后,它们都可以继续工作。

标签: asp.net-mvc-3 asp.net-mvc-4


【解决方案1】:

这里:

EditableHelpers.cs:90 

我猜你正在使用一些 NuGet 或依赖于 WebPages 2.0 的东西(又名 System.Web.WebPages, Version=2.0.0.0)。您可能更新了此 NuGet 或其他任何内容,现在您已依赖此程序集。

【讨论】:

  • 奇怪,因为我很确定自从安装 MVC4 以来我没有更改过这个类
  • 我非常怀疑。安装 MVC 4 不会破坏任何现有的 MVC 3 应用程序,我可以根据我的经验向您保证这一点。当我在我的计算机上安装 MVC 4 时,我已经有很多现有的应用程序,并且所有这些应用程序都继续完美地工作。
  • 看起来这是由 NuGet 将我的网页引用从 v1 更新到 v2 引起的。感谢您的帮助!
  • 我知道。我知道你碰了它 :-) 我准备赌 5 美元。
  • @Darin:类似的事情也发生在我身上。在我的开发盒上,我安装了 4.5 和 MVC4,但没有在服务器上。在开发盒上运行良好的 MVC3 应用程序在服务器上给了我同样的错误。我没有运行任何 NuGet 更新——不确定它是否会自动执行任何操作。我注意到 System.Web.WebPages 在 dev 上指向 v2.0。为了解决这个问题,我必须编辑 csproj 并指定它应该使用 v1.0、重新编译和重新部署。它没有指定版本,所以我猜它在 dev 上默认使用 v2.0,编译时在最终 dll 中硬编码 v2,并且由于 v2 不在服务器上......
猜你喜欢
  • 2012-11-29
  • 1970-01-01
  • 1970-01-01
  • 2022-08-19
  • 1970-01-01
  • 2019-11-07
  • 1970-01-01
  • 2013-07-08
  • 2021-12-17
相关资源
最近更新 更多