2012-10-15 58 views
5

可能重複:
MVC 4 Beta side by side installation errorMVC 3個停止MVC4安裝後工作

我有進步的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)` 

這是什麼修復?

+0

我應遵循這一點? http://stackoverflow.com/questions/9471263/mvc-4-beta-side-by-side-installation-error – amesh

回答

15

我找到了解決辦法here

安裝ASP.NET MVC 4個斷裂ASP.NET MVC 3 RTM應用。使用RTM版本創建的ASP.NET MVC 3應用程序(不是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)

+0

謝謝!在我的情況下,我只需要替換.csproj中的** **行,然後重新編譯並且確實可行!......非常感謝。 – MarioAraya

相關問題