2014-10-17 43 views
8

我昨天運行了Windows Update,並在我嘗試釋放ASP.NET MVC 4項目的新版本時引入了一些問題。窗口更新Brooke MVC應用程序

應用程序編譯,當我推的版本爲什麼要在我的網絡服務器測試站點它倒下,出現錯誤消息沒關係但是本地運行,:

System.Web.HttpCompileException: (0): error CS1705: Assembly 'App_Code, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' uses 'System.Web.Mvc, Version=4.0.0.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35' which has a higher version than referenced assembly 'System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' 

經過一番研究,我發現,這是由於從4.0.0.0到4.0.0.1的更新。我從我的項目中刪除了System.Web.Mvc dll,並且閱讀了具有更高版本的dll。再次,一切工作在本地,但不在網上。然後我瀏覽了web.config,並將4.0.0.0中的任何內容更改爲4.0.0.1。同樣,這繼續在內部工作,但在外部失敗。該錯誤信息是:

  
Could not load file or assembly 'System.Web.Mvc, Version=3.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=3.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=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded. 

WRN: Assembly binding logging is turned OFF. 
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. 
Note: There is some performance penalty associated with assembly bind failure logging. 
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog]. 

我相信這事做與我使用了錯誤處理ELMAH。

我試圖從Nuget重新安裝,如下面的建議:Windows update caused MVC3 and MVC4 stop working但這並沒有奏效,我得到了同樣的錯誤。

添加信息: 服務器尚未更新,我擔心更新此可能會破壞現有的實時版本。

+0

[ASP.NET MVC安全修補程序版本3.0.0.1打破構建]的可能重複(http://stackoverflow.com/questions/26406877/asp-net-mvc-security-patch-to-version-3- 0-0-1-break-build) – 2014-10-17 13:08:02

回答

9

錯誤消息告訴我,您在其中一個配置文件中爲MVC程序集指定了不正確的版本號。找到配置文件,使用不正確的版本,並將其更改爲與您使用的任何版本(您在上面提到的4.0.0.1)相匹配。你需要檢查所有的配置文件,包括

  • 的一個項目根
  • 的一個在瀏覽文件夾

你也可以做一個assembly redirect在你的配置文件取同樣關心這一點 - 如果由於第三方庫存而失敗,這可能是最合適的行動。

根據您的反饋ID建議使用綁定重定向。添加到您的主web.config文件..

<runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.1" /> 
     </dependentAssembly> 
    </assemblyBinding> 
    </runtime> 
+0

感謝您的回覆。我已經找到了整個解決方案,並且所有System.Web.MVC都已更改。還有其他人正在查看4.0.0.0,如System.Data.Entity。此外,錯誤消息提到了3.0.0.0,在解決方案中我找不到任何地方。 – Jay1b 2014-10-17 12:57:39

+0

@ Jay1b給綁定重定向一個鏡頭,我已更新我的帖子,以顯示你將不得不添加,使其工作。 – iamkrillin 2014-10-17 13:01:50

+0

在我的文章和你的之間我已經完成了。已經從oldVersion =「4.0.0.0-4.0.0.1」設置了重定向,我將其更改爲oldVersion =「3.0.0.0-4.0.0.1」,並在您嘗試將其更改爲oldVersion =「1.0.0.0-4.0」之後。 0.1" 。仍然沒有運氣。 – Jay1b 2014-10-17 13:18:06

0

我也有類似的問題,其中一個MS更新改變MVC.dll從3.0.0.0到3.0.0.1。我需要維護我的軟件的各種版本,以確保兼容性,我必須將3.0.0.0 dll複製到我的項目,並在構建項目之前參考它。

0

經過深入挖掘,我發現view文件夾內的web.config指向不同的版本System.web.mvc。有一次,我從4.0.0.1 改爲

<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 

從System.Web.MVC的

<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.1, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 

變化版本4.0.0.0我能解決這個問題。

+0

請在'''中編碼XML標籤 – Alexander 2015-04-14 17:25:14

相關問題