2013-02-04 27 views
17

我在我的項目中使用umbraco 4.11.3。我的項目在Windows 7上運行得很好,並在Visual Studio 2012中運行它。 但它沒有工作從Visual Studio 2012運行時贏得8!無法加載文件或程序集System.Web.Mvc

錯誤是:

Could not load file or assembly 'System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

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.IO.FileLoadException: Could not load file or assembly 'System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

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.

Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded.

=== Pre-bind state information === LOG: User = Jahan-PC\jahan LOG: DisplayName = System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 (Fully-specified) LOG: Appbase = file:///G:/20130204/SourceCode/Defraz.Movafaqiyat.WebApp/Defraz.Movafaqiyat.WebApp/ LOG: Initial PrivatePath = G:\20130204\SourceCode\Defraz.Movafaqiyat.WebApp\Defraz.Movafaqiyat.WebApp\bin Calling assembly : ClientDependency.Core.Mvc, Version=1.5.1.0, Culture=neutral, PublicKeyToken=null. === LOG: This bind starts in default load context. LOG: Using application configuration file: G:\20130204\SourceCode\Defraz.Movafaqiyat.WebApp\Defraz.Movafaqiyat.WebApp\web.config LOG: Using host configuration file: C:\Users\jahan\Documents\IISExpress\config\aspnet.config LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config. LOG: Post-policy reference: System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 LOG: Attempting download of new URL file:///C:/Users/jahan/AppData/Local/Temp/Temporary ASP.NET Files/root/bc5b37d0/42db0b24/System.Web.Mvc.DLL. LOG: Attempting download of new URL file:///C:/Users/jahan/AppData/Local/Temp/Temporary ASP.NET Files/root/bc5b37d0/42db0b24/System.Web.Mvc/System.Web.Mvc.DLL. LOG: Attempting download of new URL file:///G:/20130204/SourceCode/Defraz.Movafaqiyat.WebApp/Defraz.Movafaqiyat.WebApp/bin/System.Web.Mvc.DLL. WRN: Comparing the assembly name resulted in the mismatch: Major Version ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

Stack Trace:

[FileLoadException: Could not load file or assembly 'System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
ClientDependency.Core.Mvc.MvcFilter.ValidateCurrentHandler() +0
ClientDependency.Core.Module.ClientDependencyModule.b__0(IFilter f) +31 System.Linq.Enumerable.Any(IEnumerable 1 source, Func 2 predicate) +146
ClientDependency.Core.Module.ClientDependencyModule.ValidateCurrentHandler(IEnumerable`1 filters) +127
ClientDependency.Core.Module.ClientDependencyModule.HandleRequest(Object sender, EventArgs e) +179
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +136 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69

注:在IIS上發佈的項目運作良好的Win7和Win8的。 我的項目不是基於ASP.NET MVC。 請幫幫我。

+1

是.NET 2.0支持安裝到您的IIS Web服務器?如果是的話,應用程序設置使用正確的應用程序池?應該添加.net 3.5支持,然後你需要ASP.NET MVC框架,我會建議按照這個順序安裝1,2,3和4,以保持文件到位 –

+0

@MartinBarker下載所有的MVC版本是_not_ the解決這個問題的方法,因爲它只會掩蓋潛在的問題,並可能在這個用戶的未來項目中傳播同樣的問題。 – Digbyswift

+1

@MartinBarker:非常感謝。我在win8上從http://www.microsoft.com/en-us/download/details.aspx?id=22079安裝了ASP.NET MVC2,並解決了我的問題。 – Jahan

回答

12

我們使用Azure雲來運行部署,並且出現同樣的錯誤。由於您無法真正將軟件包安裝到服務器實例上,因此解決此問題的方法是進入您的項目的參考,查找對抱怨缺失的庫的引用,進入屬性,然後將Copy Local設置爲True。重新部署,你全都準備好了。

6

我假設這是一臺新機器,看到你有新的操作系統和不同版本的Visual Studio。我認爲你需要安裝MVC Framework版本2,因爲這是你的Umbraco安裝所期望的。您可以安裝框架,並將DLL導入到您的GAC中,或者將您的良好系統中的DLL複製到Web應用程序的bin文件夾中。

注意,你說你的項目「不使用」MVC,但我認爲你會發現Umbraco。無論如何,這個錯誤告訴你係統希望找到它。

+0

:非常感謝。我在win8上從microsoft.com/en-us/download/details.aspx?id=22079安裝了ASP.NET MVC2,並解決了我的問題。 – Jahan

3

Umbraco 4.11.3不使用MVC2,它使用MVC3,所以我猜你在你的web.config中有一個引用到MVC2庫,可能在compilation > assemblies部分。它應該看起來像這樣:

<compilation defaultLanguage="c#" batch="false" targetFramework="4.0" debug="true"> 
    <assemblies> 
    <!-- ASP.NET 4.0 Assemblies --> 
    <add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" /> 
    <add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /> 
    <add assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
    <add assembly="System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /> 
    <add assembly="System.Data.DataSetExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /> 
    <add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
    <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> 
    <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
    <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
    <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
    <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
    </assemblies> 
    <!-- Added in Umbraco 4.6.2 --> 
    <buildProviders> 
    <add extension=".cshtml" type="umbraco.MacroEngines.RazorBuildProvider, umbraco.MacroEngines" /> 
    <add extension=".vbhtml" type="umbraco.MacroEngines.RazorBuildProvider, umbraco.MacroEngines" /> 
    <add extension=".razor" type="umbraco.MacroEngines.RazorBuildProvider, umbraco.MacroEngines" /> 
    </buildProviders> 
    <!-- End of added in Umbraco 4.6.2 --> 
</compilation> 
+0

在我的web.config中編譯>程序集部分: Jahan

+2

好的,但是你發佈的錯誤確實指向配置文件中對版本2的引用。你檢查了web.config的其餘部分嗎?爲明顯的問題道歉。 – Digbyswift

+0

感謝您關注我的問題,但Jonathan解決方案非常完美。 – Jahan

4

此問題的正確解決方法是:

  1. ReferencesSolution Explorer右鍵單擊並選擇Manage NuGet Packages
  2. 在左側選擇Updates
  3. 在中間部分選擇Microsoft ASP.NET MVC
  4. 您應該看到一個Update按鈕出現在您的選擇中,點擊它

就是這樣......接受任何可能彈出的T & Cs,或者在本地發佈或運行您的項目。如果您在本地運行項目時仍遇到問題,請嘗試關閉Visual Studio,刪除該項目的.SUO文件,然後再次嘗試打開該解決方案...嘗試再次運行。

+0

感謝人,我有點討厭ASP.NET這些東西 –

+1

在我們深入研究東西並創造更多問題之前,一個很簡單容易的步驟就可以抓住許多這樣的問題。謝謝!! – Alan

相關問題