.net Windows 更新导致 MVC3 和 MVC4 停止工作
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26393157/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Windows update caused MVC3 and MVC4 stop working
提问by Yogurtu
am i the only one who installed a Windows Update (8.1) on october 15, and suddenly MVC stop working because of this warning?
我是唯一一个在 10 月 15 日安装了 Windows 更新 (8.1) 的人,但由于此警告,MVC 突然停止工作吗?
Warning 1 Could not resolve this reference. Could not locate the assembly "System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
警告 1 无法解析此引用。无法找到程序集“System.Web.Mvc,版本=4.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,processorArchitecture=MSIL”。检查以确保程序集存在于磁盘上。如果您的代码需要此引用,您可能会收到编译错误。
It seems that this windows update installs a newer version of MVC with version number 4.0.0.1, and removes old version from program files folder.
似乎此 Windows 更新安装了版本号为 4.0.0.1 的较新版本的 MVC,并从程序文件文件夹中删除了旧版本。
Someone know how to fix this without crawling for each project?
有人知道如何在不为每个项目爬行的情况下解决这个问题吗?
采纳答案by Krzysztof Kalinowski
The best solution is update DLL to version 4.0.0.1. Try use nuget:
最好的解决方案是将 DLL 更新到 4.0.0.1 版。尝试使用nuget:
Install-Package Microsoft.AspNet.Mvc -Version 4.0.40804 -Project <your project name>
This will automatically update
这将自动更新
<dependentAssembly> <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="0.0.0.0-4.0.0.1" newVersion="4.0.0.1" /> </dependentAssembly>
<dependentAssembly> <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="0.0.0.0-4.0.0.1" newVersion="4.0.0.1" /> </dependentAssembly>
You just have to edit version System.Web.Mvc manually in:
您只需要在以下位置手动编辑 System.Web.Mvc 版本:
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Mvc, Version=4.0.0.1, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
回答by Zach La Lond
We had to manually touch each .csprojto update the version from 4.0.0.0to 4.0.0.1to get our builds going. Quite a pain.
我们必须手动触摸每个.csproj以将版本从4.0.0.0更新到4.0.0.1才能进行构建。相当痛苦。
New references should look like:
新的参考应该是这样的:
<Reference Include="System.Web.Mvc, Version=4.0.0.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
回答by Jaws
Had the same issue after update:
更新后有同样的问题:
Security Update for Microsoft ASP.NET MVC 4.0 (KB2993928)
http://support.microsoft.com/kb/2993928
Microsoft ASP.NET MVC 4.0 安全更新 (KB2993928)
http://support.microsoft.com/kb/2993928
But only for project with a reference to the System.Web.Mvc, not installed by package.
My colleague, who hadn't installed Microsoft ASP.NET MVC 4.0 Runtime and didn't received the update, had no trouble and had still the reference to 4.0.0.0, not to 4.0.0.1
I manually changed the reference to 4.0.0.1, after check-in, my colleague could still build with a reference to 4.0.0.0.
(Working both on Win7 Pro SP1, VS2013 Pro Update 3)
但仅适用于引用 System.Web.Mvc 的项目,而不是通过包安装。
我的同事没有安装 Microsoft ASP.NET MVC 4.0 运行时也没有收到更新,没有问题,仍然引用 4.0.0.0,而不是 4.0.0.1
我手动将引用更改为 4.0.0 . 1、check-in后同事还是可以参考4.0.0建的。0.
(Win7 Pro SP1, VS2013 Pro Update 3 均可使用)
回答by Miguel Lacouture
Please see this blog, the recommended way is to update corresponding NuGet package:
请看这篇博客,推荐的方式是更新对应的NuGet包:
To quote:
报价:
The problem can be resolved by implemented one of the following solutions:
(Preferred) Install Microsoft.AspNet.Mvc from the NuGet gallery (this will install a binding redirect in your web.config). You can do this from the NuGet package manager or the NuGet console inside Visual Studio:
Install-Package Microsoft.AspNet.Mvc -Version -Project PROJECTNAME
MVC 4 version: 4.0.40804.0
MVC 3 version: 3.0.50813.1
Manually update the reference to System.Web.MVC.dll (don't use the one in the GAC).
Try the Add Reference -> Assemblies -> Extensions dialog box.
该问题可以通过实施以下解决方案之一来解决:
(首选)从 NuGet 库安装 Microsoft.AspNet.Mvc(这将在您的 web.config 中安装绑定重定向)。您可以从 NuGet 包管理器或 Visual Studio 中的 NuGet 控制台执行此操作:
安装包 Microsoft.AspNet.Mvc -Version -Project PROJECTNAME
MVC 4 版本:4.0.40804.0
MVC 3 版本:3.0.50813.1
手动更新对 System.Web.MVC.dll 的引用(不要使用 GAC 中的引用)。
尝试添加引用 -> 程序集 -> 扩展对话框。
回答by e4rthdog
See this: Microsoft Asp.Net MVC Security Update MS14-059 broke my build!MS blogged about it since it obviously brought a lot of confusion
请参阅:Microsoft Asp.Net MVC 安全更新 MS14-059 破坏了我的构建!MS 写了关于它的博客,因为它显然带来了很多混乱
回答by THN
For web project, you may have to update the configuration in the web.config as well:
对于 web 项目,您可能还需要更新 web.config 中的配置:
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.1"/>
</dependentAssembly>
回答by Robert Benyi
You need to change all the references to System.Web.Mvc within your solution. Just delete them and add the new 4.0.0.1 version.
您需要更改解决方案中对 System.Web.Mvc 的所有引用。只需删除它们并添加新的 4.0.0.1 版本即可。
Also in the properties change copy localto true.
同样在属性更改copy local为true。
And in the web.config add the assambly binding to point to the new version of mvc:
并在 web.config 中添加 assambly 绑定以指向新版本的 mvc:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.1" newVersion="4.0.0.1" />
</dependentAssembly>
</assemblyBinding>
</runtime>
回答by edencorbin
Okay,
好的,
For me it was two simple steps:
对我来说,这是两个简单的步骤:
First I changed all references to System.Web.Mvc from 4.0.0.0 to 4.0.0.1,
首先,我将 System.Web.Mvc 的所有引用从 4.0.0.0 更改为 4.0.0.1,
Then I had to go to the properties of System.Web.Mvc (possibly because I had removed and re-added it) and change copy local to true.
然后我不得不转到 System.Web.Mvc 的属性(可能是因为我已经删除并重新添加了它)并将本地副本更改为 true。
Hope this is helpful for somebody.
希望这对某人有帮助。
回答by Ricardo Sanchez
If you are still getting the same error after trying @Krzysztof solution or any of the other answers above, one work around that might work for you is to uninstallMVC Runtime 4.0
如果您在尝试@Krzysztof 解决方案或上述任何其他答案后仍然遇到相同的错误,可能对您有用的一种解决方法是卸载MVC Runtime 4.0

