MVC 3 安装 MVC4 后停止工作 [重复]

2023-12-26

可能的重复:
MVC 4 Beta 并排安装错误 https://stackoverflow.com/questions/9471263/mvc-4-beta-side-by-side-installation-error

我正在开发一个 MVC3 应用程序。我想在 MVC4 中启动另一个应用程序。但是 MVC 3 应用程序在安装 MVC 4(不是测试版)后停止工作。收到一些 dll 冲突错误。其中一个错误是这样的。

The type 'System.Web.Helpers.Json' exists in both 'c:\Windows\Microsoft.NET\assembly\GAC_MSIL    \System.Web.Helpers\v4.0_2.0.0.0__31bf3856ad364e35\System.Web.Helpers.dll' and 'c:\Windows    \Microsoft.NET\assembly\GAC_MSIL\System.Web.Helpers    \v4.0_1.0.0.0__31bf3856ad364e35\System.Web.Helpers.dll' `at      System.Web.Compilation.AssemblyBuilder.Compile()
   at System.Web.Compilation.BuildProvidersCompiler.PerformBuild()
   at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath)
   at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean    noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean    ensureIsUpToDate)
   at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context,    VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile,    Boolean throwIfNotFound, Boolean ensureIsUpToDate)
   at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath,    HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound)
   at System.Web.Compilation.BuildManager.GetObjectFactory(String virtualPath, Boolean throwIfNotFound)
   at System.Web.Mvc.BuildManagerWrapper.System.Web.Mvc.IBuildManager.FileExists(String virtualPath)
   at System.Web.Mvc.BuildManagerViewEngine.FileExists(ControllerContext controllerContext, String   virtualPath)
   at System.Web.Mvc.VirtualPathProviderViewEngine.GetPathFromGeneralName(ControllerContext controllerContext, List`1 locations, String name, String controllerName, String areaName, String cacheKey, String[]& searchedLocations)
   at System.Web.Mvc.VirtualPathProviderViewEngine.GetPath(ControllerContext controllerContext, String[] locations, String[] areaLocations, String locationsPropertyName, String name, String controllerName, String cacheKeyPrefix, Boolean useCache, String[]& searchedLocations)
   at System.Web.Mvc.VirtualPathProviderViewEngine.FindView(ControllerContext controllerContext, String viewName, String masterName, Boolean useCache)
   at System.Web.Mvc.ViewEngineCollection.<>c__DisplayClassc.<FindView>b__b(IViewEngine e)
   at System.Web.Mvc.ViewEngineCollection.Find(Func`2 lookup, Boolean trackSearchedPaths)
   at System.Web.Mvc.ViewEngineCollection.Find(Func`2 cacheLocator, Func`2 locator)
   at System.Web.Mvc.ViewEngineCollection.FindView(ControllerContext controllerContext, String viewName, String masterName)
   at System.Web.Mvc.ViewResult.FindView(ControllerContext context)
   at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult)
   at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19()
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)
   at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1c.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b()
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)
   at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1c.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b()
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult)
   at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)`

有什么办法可以解决这个问题?


我找到了解决方案here http://www.asp.net/whitepapers/mvc4-release-notes#_Toc303253815

安装 ASP.NET MVC 4 会破坏 ASP.NET MVC 3 RTM 应用程序。使用 RTM 版本(而不是使用 ASP.NET MVC 3 Tools Update 版本)创建的 ASP.NET MVC 3 应用程序需要进行以下更改才能与 ASP.NET MVC 4 并行工作。进行这些更新会导致编译错误。 所需更新

在根 Web.config 文件中,添加一个包含键 webPages:Version 和值 1.0.0.0 的新条目。

<appSettings>
<add key="webpages:Version" value="1.0.0.0"/>
<add key="ClientValidationEnabled" value="true"/>
<add key="UnobtrusiveJavaScriptEnabled" value="true"/>
</appSettings>

在“解决方案资源管理器”中,右键单击项目名称,然后选择“卸载项目”。然后再次右键单击该名称并选择编辑 ProjectName.csproj。 找到以下程序集引用:

<Reference Include="System.Web.WebPages"/> 
<Reference Include="System.Web.Helpers" />

将它们替换为以下内容:

<Reference Include="System.Web.WebPages, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL "/> 
<Reference Include="System.Web.Helpers, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />

保存更改,关闭正在编辑的项目 (.csproj) 文件,然后右键单击该项目并选择“重新加载”。

(您可以手动编辑MVC项目文件文本编辑器还。右键单击 .csproj 文件并使用任何文本编辑器打开并仔细编辑 xml)

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

MVC 3 安装 MVC4 后停止工作 [重复] 的相关文章

随机推荐