Dot-Net

Windows 更新導致 MVC3 和 MVC4 停止工作

  • October 15, 2014

我是唯一一個在 10 月 15 日安裝了 Windows 更新(8.1)的人,但由於這個警告,MVC 突然停止工作?

警告 1 無法解析此引用。找不到程序集“System.Web.Mvc,Version=4.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,processorArchitecture=MSIL”。檢查以確保該程序集存在於磁碟上。如果您的程式碼需要此引用,您可能會遇到編譯錯誤。

似乎此 Windows 更新安裝了版本號為 4.0.0.1 的較新版本的 MVC,並從程序文件夾中刪除了舊版本。

有人知道如何在不為每個項目爬行的情況下解決這個問題嗎?

最好的解決方案是將 DLL 更新到版本 4.0.0.1。嘗試使用 nuget:

Install-Package Microsoft.AspNet.Mvc -Version 4.0.40804 -Project <your project name>

這會自動更新

  <dependentAssembly>
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="0.0.0.0-4.0.0.1" newVersion="4.0.0.1" />
  </dependentAssembly>

您只需在以下位置手動編輯 System.Web.Mvc 版本:

<compilation debug="true" targetFramework="4.0">
 <assemblies>
   <add assembly="System.Web.Mvc, Version=4.0.0.1, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

引用自:https://stackoverflow.com/questions/26393157